Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use own implementation of 'sleep' command for tests
- Loading branch information
Showing
3 changed files
with
55 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Platform independent implementation of 'sleep' used as a command in tests | ||
* | ||
* (Windows doesn't provide the 'sleep' command by default, | ||
* see https://github.com/open-cli-tools/concurrently/issues/277) | ||
*/ | ||
|
||
/* eslint-disable no-console */ | ||
async function run(s) { | ||
await new Promise(resolve => setTimeout(resolve, s * 1000)); | ||
} | ||
|
||
const s = process.argv[2]; | ||
if (!s || isNaN(s) || process.argv.length > 3) { | ||
// Mimic behavior from native 'sleep' command | ||
console.error(`usage: sleep seconds`); | ||
process.exit(1); | ||
} | ||
run(s); |