Merge branch 'master' into release/7.x
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by John Gee · parents f76bc71, e0e7238 · Browse files · 3 files·+24 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+24 added−17 removed
- tests:+17 added−17 removed
- other:+7 added−0 removed
Provenance
- Commit
5fd6e88- Tree
a581591- Author
John Gee <john@ruru.gen.nz>- Committer
John Gee <john@ruru.gen.nz>- Parent 1
f76bc71- Parent 2
e0e7238
3 files changed+24 added−17 removed
modified:tests/command.default.test.js+4 added-4 removed
123456678910111213131415161718181920212223232425262767 unmodified linesconst childProcess = require('child_process');const commander = require('../');const path = require('path');const util = require('util');
const execAsync = util.promisify(childProcess.exec);const execFileAsync = util.promisify(childProcess.execFile);
describe('default executable command', () => { // Calling node explicitly so pm works without file suffix cross-platform. const pm = path.join(__dirname, './fixtures/pm');
test('when default subcommand and no command then call default', async() => { const { stdout } = await execAsync(`node ${pm}`); const { stdout } = await execFileAsync('node', [pm]); expect(stdout).toBe('default\n'); });
test('when default subcommand and unrecognised argument then call default with argument', async() => { const { stdout } = await execAsync(`node ${pm} an-argument`); const { stdout } = await execFileAsync('node', [pm, 'an-argument']); expect(stdout).toBe("default\n[ 'an-argument' ]\n"); });
test('when default subcommand and unrecognised option then call default with option', async() => { const { stdout } = await execAsync(`node ${pm} --an-option`); const { stdout } = await execFileAsync('node', [pm, '--an-option']); expect(stdout).toBe("default\n[ '--an-option' ]\n"); });});
67 unmodified linesmodified:tests/command.executableSubcommand.lookup.test.js+13 added-13 removed
1234456783 unmodified lines121314151616171819205 unmodified lines262728293030313233344 unmodified lines3940414243434445464748484950515253535455565758585960616263636465666768686970717273747475767778798080818283848586878889899091929394949596const childProcess = require('child_process');const path = require('path');const util = require('util');const execAsync = util.promisify(childProcess.exec);const execFileAsync = util.promisify(childProcess.execFile);
// Calling node explicitly so pm works without file suffix cross-platform.
// Get false positives due to use of testOrSkipOnWindows3 unmodified linesconst pm = path.join(__dirname, './fixtures/pm');
test('when subcommand file missing then error', () => { expect.assertions(1); return execAsync(`node ${pm} list`).catch((err) => { return execFileAsync('node', [pm, 'list']).catch((err) => { if (process.platform === 'win32') { // Get uncaught thrown error on Windows // eslint-disable-next-line jest/no-conditional-expect expect(err.stderr).toBeDefined();5 unmodified lines});
test('when alias subcommand file missing then error', () => { expect.assertions(1); return execAsync(`node ${pm} lst`).catch((err) => { return execFileAsync('node', [pm, 'lst']).catch((err) => { if (process.platform === 'win32') { // Get uncaught thrown error on Windows // eslint-disable-next-line jest/no-conditional-expect expect(err.stderr).toBeDefined();4 unmodified lines });});
test('when subcommand file has no suffix then lookup succeeds', async() => { const { stdout } = await execAsync(`node ${pm} install`); const { stdout } = await execFileAsync('node', [pm, 'install']); expect(stdout).toBe('install\n');});
test('when alias subcommand file has no suffix then lookup succeeds', async() => { const { stdout } = await execAsync(`node ${pm} i`); const { stdout } = await execFileAsync('node', [pm, 'i']); expect(stdout).toBe('install\n');});
test('when subcommand target executablefile has no suffix then lookup succeeds', async() => { const { stdout } = await execAsync(`node ${pm} specifyInstall`); const { stdout } = await execFileAsync('node', [pm, 'specifyInstall']); expect(stdout).toBe('install\n');});
test('when subcommand file suffix .js then lookup succeeds', async() => { const { stdout } = await execAsync(`node ${pm} publish`); const { stdout } = await execFileAsync('node', [pm, 'publish']); expect(stdout).toBe('publish\n');});
test('when alias subcommand file suffix .js then lookup succeeds', async() => { const { stdout } = await execAsync(`node ${pm} p`); const { stdout } = await execFileAsync('node', [pm, 'p']); expect(stdout).toBe('publish\n');});
test('when subcommand target executablefile has suffix .js then lookup succeeds', async() => { const { stdout } = await execAsync(`node ${pm} specifyPublish`); const { stdout } = await execFileAsync('node', [pm, 'specifyPublish']); expect(stdout).toBe('publish\n');});
testOrSkipOnWindows('when subcommand file is symlink then lookup succeeds', async() => { const pmlink = path.join(__dirname, 'fixtures', 'pmlink'); const { stdout } = await execAsync(`node ${pmlink} install`); const { stdout } = await execFileAsync('node', [pmlink, 'install']); expect(stdout).toBe('install\n');});
testOrSkipOnWindows('when subcommand file is double symlink then lookup succeeds', async() => { const pmlink = path.join(__dirname, 'fixtures', 'another-dir', 'pm'); const { stdout } = await execAsync(`node ${pmlink} install`); const { stdout } = await execFileAsync('node', [pmlink, 'install']); expect(stdout).toBe('install\n');});
test('when subcommand suffix is .ts then lookup succeeds', async() => { // We support looking for ts files for ts-node in particular, but don't need to test ts-node itself. // The program and the subcommand `pm-install.ts` are both plain JavaScript code. const binLinkTs = path.join(__dirname, 'fixtures-ts', 'pm.ts'); // childProcess.execFile('node', ['-r', 'ts-node/register', binLinkTs, 'install'], function(_error, stdout, stderr) { const { stdout } = await execAsync(`node ${binLinkTs} install`); const { stdout } = await execFileAsync('node', [binLinkTs, 'install']); expect(stdout).toBe('install\n');});
test('when subsubcommand then lookup sub-sub-command', async() => { const { stdout } = await execAsync(`node ${pm} cache clear`); const { stdout } = await execFileAsync('node', [pm, 'cache', 'clear']); expect(stdout).toBe('cache-clear\n');});modified:CHANGELOG.md+7 added
144 unmodified lines145 - document and annotate deprecated routines ([#1349])146 - deprecated callback parameter to `.help()` and `.outputHelp()` (removed from README) ([#1296])147 - deprecate `.on('--help')` (removed from README) ([#1296])148 - initialise the command description to empty string (previously undefined) ([#1365])149+## [6.2.1] (2020-12-13)150 151+### Fixed152+153+- some tests failed if directory path included a space ([1390])154+155 ## [6.2.0] (2020-10-25)156 157 ### Added158 224 unmodified lines383 [#1368]: https://github.com/tj/commander.js/pull/1368384 [#1375]: https://github.com/tj/commander.js/pull/1375385 [#1380]: https://github.com/tj/commander.js/pull/1380386 [#1387]: https://github.com/tj/commander.js/pull/1387387+[#1390]: https://github.com/tj/commander.js/pull/1390388 389 [Unreleased]: https://github.com/tj/commander.js/compare/master...develop390 [7.0.0-1]: https://github.com/tj/commander.js/compare/v7.0.0-0...v7.0.0-1391 [7.0.0-0]: https://github.com/tj/commander.js/compare/v6.2.0...v7.0.0-0392+[6.2.1]: https://github.com/tj/commander.js/compare/v6.2.0..v6.2.1393 [6.2.0]: https://github.com/tj/commander.js/compare/v6.1.0..v6.2.0394 [6.1.0]: https://github.com/tj/commander.js/compare/v6.0.0..v6.1.0395 [6.0.0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0396 [6.0.0-0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0-07 unmodified lines