-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add command-exists test to axioms for stability, moved from sync…
… to async calls (#182)
- Loading branch information
1 parent
ebca0b1
commit 0da11b9
Showing
9 changed files
with
66 additions
and
39 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,31 @@ | ||
// Copyright 2017 TODO Group. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
const commandExistsLib = require('command-exists') | ||
|
||
/** | ||
* Checks whether or not a list of commands exists in the | ||
* current environment. Returns the first command that was | ||
* found to exist. | ||
* | ||
* @protected | ||
* @param {string|string[]} command The command or commands to check for. | ||
* @returns {string|null} The first command found to exist, or null of none were found. | ||
*/ | ||
async function commandExists (command) { | ||
// convert to array if needed | ||
if (!Array.isArray(command)) { | ||
command = [command] | ||
} | ||
for (const commandString of command) { | ||
try { | ||
await commandExistsLib(commandString) | ||
return commandString | ||
} catch (e) { | ||
// do nothing | ||
} | ||
} | ||
return null | ||
} | ||
|
||
module.exports.commandExists = commandExists |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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