Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔬 #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm install
- run: npm t
- run: npm run build
- run: npm publish
- if: github.ref == 'refs/heads/master'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool. I didn't know you could do this nowadays

run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.*
test.js
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
4,419 changes: 0 additions & 4,419 deletions package-lock.json

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"module": "dist/wait.module.js",
"unpkg": "dist/wait.umd.js",
"typings": "wait.d.ts",
"type": "module",
"name": "wait",
"author": "ealush",
"bin": {
"wait": "./cli.js"
},
"scripts": {
"build": "microbundle",
"dev": "microbundle watch"
"dev": "microbundle watch",
"test": "./test.js"
},
"repository": {
"type": "git",
Expand Down
35 changes: 35 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

import wait from './wait.js'

const tests = [];

tests.push(async () => {
let ran = false;
const promise = wait().then(() => {
ran = true;
});
if (ran !== false) {
return 'Did not wait to execute promise resolve';
}
await promise;
if (ran !== true) {
return 'Did not execute promise resolve';
}
});

tests.push(async () => {
const start = Date.now();
await wait(100);
const duration = Date.now() - start;
if (duration < 100 || duration > 111) {
return `Waited ${duration} ms instead of 100 ms`;
}
});

console.log(`Run ${tests.length} tests…`)
const messages = await Promise.all(
tests.map(test => test())
).then(results => results.filter(Boolean));
console.log(messages.join('\n') || 'Everything is fine');
process.exit(messages.length);