-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): warn on unknown commands (#1304)
Emit a warning and exit with status code 1. Based on tj/commander.js#1088 (comment)
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
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 @@ | ||
import chai, { expect } from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import path from 'path'; | ||
import spawnPromise from 'cross-spawn-promise'; | ||
|
||
chai.use(chaiAsPromised); | ||
|
||
function tsNodePath() { | ||
const tsNode = path.resolve(__dirname, '../../../../node_modules/.bin/ts-node'); | ||
return process.platform === 'win32' ? `${tsNode}.cmd` : tsNode; | ||
} | ||
|
||
describe('cli', () => { | ||
it('should fail on unknown subcommands', async () => { | ||
const error = await expect(spawnPromise(tsNodePath(), [path.resolve(__dirname, '../src/electron-forge.ts'), 'nonexistent'])).to.eventually.be.rejected; | ||
expect(error.exitStatus).to.equal(1); | ||
expect(error.stderr.toString()).to.match(/Unknown command "nonexistent"/); | ||
}); | ||
}); |