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

fix: add check cmd #20

Closed
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ npm-debug.log
coverage/
test/fixtures/ts/**/*.js
.DS_Store
package-lock.json
18 changes: 17 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
const path = require('path');
const spawn = require('child_process').spawn;

function isCmd() {
if (os.platform() !== 'win32') {

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 12)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 8)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 10)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 12)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 12)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 10)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 8)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 10)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

'os' is not defined

Check failure on line 10 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 8)

'os' is not defined
return false
}

try {
const result = spawnSync(`ls`, {

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 12)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 8)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 10)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 12)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 12)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 10)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 8)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 10)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

'spawnSync' is not defined

Check failure on line 15 in index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 8)

'spawnSync' is not defined
stdio: 'pipe',
})

return result.error !== undefined
} catch (err) {
return true
}
}

/**
* Run shell script in child process
* Support OSX, Linux and Windows
Expand All @@ -29,7 +45,7 @@
let sh = 'sh';
let shFlag = '-c';

if (process.platform === 'win32') {
if (process.platform === 'win32' && isCmd()) {
sh = process.env.comspec || 'cmd';
shFlag = '/d /s /c';
options.windowsVerbatimArguments = true;
Expand Down
Loading