Fix formatting, whitespace, markdownlint (#9) (#40)

Co-authored-by: Frieder Bluemle <frieder.bluemle@gmail.com>
This commit is contained in:
Ross Brodbeck 2020-07-20 07:08:15 -04:00 committed by GitHub
parent b447b178e1
commit c0941600fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 55 additions and 56 deletions

1
.eslintignore Normal file
View File

@ -0,0 +1 @@
dist/

4
.gitignore vendored
View File

@ -1,7 +1,9 @@
node_modules/
# Editors
.vscode
.vscode/
.idea/
*.iml
# Logs
logs

View File

@ -1,10 +1,9 @@
# Create a JavaScript Action
<p align="center">
<a href="https://github.com/actions/javascript-action/actions"><img alt="javscript-action status" src="https://github.com/actions/javascript-action/workflows/units-test/badge.svg"></a>
</p>
# Create a JavaScript Action
Use this template to bootstrap the creation of a JavaScript action.:rocket:
This template includes tests, linting, a validation workflow, publishing, and versioning guidance.
@ -18,11 +17,13 @@ Click the `Use this Template` and provide the new repo details for your action
## Code in Main
Install the dependencies
```bash
$ npm install
npm install
```
Run the tests :heavy_check_mark:
```bash
$ npm test
@ -30,7 +31,6 @@ $ npm test
✓ throws invalid number (3ms)
✓ wait 500 ms (504ms)
✓ test runs (95ms)
...
```
@ -89,12 +89,12 @@ Users shouldn't consume the action from master since that would be latest code a
Checkin to the v1 release branch
```bash
$ git checkout -b v1
$ git commit -a -m "v1 release"
git checkout -b v1
git commit -a -m "v1 release"
```
```bash
$ git push origin v1
git push origin v1
```
Your action is now published! :rocket:

20
dist/index.js vendored
View File

@ -67,20 +67,19 @@ const wait = __webpack_require__(949);
async function run() {
try {
const ms = core.getInput('milliseconds');
core.info(`Waiting ${ms} milliseconds ...`)
core.info(`Waiting ${ms} milliseconds ...`);
core.debug((new Date()).toTimeString()) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
core.debug((new Date()).toTimeString()); // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
await wait(parseInt(ms));
core.info((new Date()).toTimeString())
core.info((new Date()).toTimeString());
core.setOutput('time', new Date().toTimeString());
}
catch (error) {
} catch (error) {
core.setFailed(error.message);
}
}
run()
run();
/***/ }),
@ -353,14 +352,13 @@ module.exports = require("path");
/***/ (function(module) {
let wait = function (milliseconds) {
return new Promise((resolve, reject) => {
if (typeof(milliseconds) !== 'number') {
throw new Error('milleseconds not a number');
return new Promise((resolve) => {
if (typeof milliseconds !== 'number') {
throw new Error('milliseconds not a number');
}
setTimeout(() => resolve("done!"), milliseconds)
});
}
};
module.exports = wait;

View File

@ -6,17 +6,16 @@ const wait = require('./wait');
async function run() {
try {
const ms = core.getInput('milliseconds');
core.info(`Waiting ${ms} milliseconds ...`)
core.info(`Waiting ${ms} milliseconds ...`);
core.debug((new Date()).toTimeString()) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
core.debug((new Date()).toTimeString()); // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
await wait(parseInt(ms));
core.info((new Date()).toTimeString())
core.info((new Date()).toTimeString());
core.setOutput('time', new Date().toTimeString());
}
catch (error) {
} catch (error) {
core.setFailed(error.message);
}
}
run()
run();

View File

@ -4,7 +4,7 @@ const cp = require('child_process');
const path = require('path');
test('throws invalid number', async () => {
await expect(wait('foo')).rejects.toThrow('milleseconds not a number');
await expect(wait('foo')).rejects.toThrow('milliseconds not a number');
});
test('wait 500 ms', async () => {

View File

@ -4,7 +4,7 @@
"description": "JavaScript Action Template",
"main": "index.js",
"scripts": {
"lint": "eslint index.js",
"lint": "eslint .",
"prepare": "ncc build index.js -o dist --source-map",
"test": "jest",
"all": "npm run lint && npm run prepare && npm run test"

View File

@ -1,11 +1,10 @@
let wait = function (milliseconds) {
return new Promise((resolve, reject) => {
if (typeof(milliseconds) !== 'number') {
throw new Error('milleseconds not a number');
return new Promise((resolve) => {
if (typeof milliseconds !== 'number') {
throw new Error('milliseconds not a number');
}
setTimeout(() => resolve("done!"), milliseconds)
});
}
};
module.exports = wait;