command.executableSubcommand.search.test.js
This file
Path
tests/command.executableSubcommand.search.test.js
315 lines · 12.1 KiB · JavaScript
Last changed by
Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
History of this fileTake it
The walk stopped after 200 commits: lines older than cc2db5b point at it.
Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 1–4why, one step back1const childProcess = require('child_process');2const fs = require('fs');3const path = require('path');4const commander = require('../');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 5–6why, one step back5const { test, describe } = require('node:test');6const assert = require('node:assert/strict');Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 7–12why, one step back78// This file does in-process mocking. Bit clumsy but faster and less external clutter than using fixtures.9// See also command.executableSubcommand.lookup.test.js for tests using fixtures.1011const gLocalDirectory = path.resolve(__dirname, 'fixtures'); // Real directory, although not actually searching for files in it.12Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 13–21why, one step back13function extractMockSpawnArgs(spawnSpy) {14 assert.equal(spawnSpy.mock.callCount() > 0, true);15 // This is very fragile on implementation details of how subcommand spawned.16 // non-Win Jest, launchWithNode: childProcess.spawn(process.argv[0], args, { stdio: 'inherit' });17 // Win Jest always: childProcess.spawn(process.execPath, args, { stdio: 'inherit' });18 // node:test passes wild number of node args on front!1920 const callArgs = spawnSpy.mock.calls[0].arguments;21 return callArgs[1].slice(-1); // fingers crossed last arg is filename!Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 22–23why, one step back22}23Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 24–25why, one step back24function extractMockSpawnCommand(spawnSpy) {25 assert.equal(spawnSpy.mock.callCount() > 0, true);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 26why, one step back26 // child_process.spawn(command[, args][, options])Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 27–28why, one step back27 const callArgs = spawnSpy.mock.calls[0].arguments;28 return callArgs[0];Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 29–30why, one step back29}30Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 31–32why, one step back31const describeOrSkipOnWindows =32 process.platform === 'win32' ? describe.skip : describe;Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 33–34why, one step back3334describe('search for subcommand', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 35–36why, one step back35 function makeSpies(t, existsFn) {36 const spawnSpy = t.mock.method(childProcess, 'spawn', () => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 37–38why, one step back37 return {38 on: () => {},Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 39why, one step back39 killed: true,Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 40–41why, one step back40 };41 });Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 42–44why, one step back42 const existsSpy = t.mock.method(fs, 'existsSync', existsFn);43 return { spawnSpy, existsSpy };44 }Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 45why, one step back45Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf
line 46why, one step back46 // fs.existsSync gets called on Windows outside the search, so skip the tests (or come up with a different way of checking).Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 47why, one step back47 describe('whether perform search for local files', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 48–49why, one step back48 test('when no script arg or executableDir then no search for local file', (t) => {49 const { existsSpy } = makeSpies(t, () => false);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 50why, one step back50 const program = new commander.Command();Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf
line 51why, one step back51 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawnAdd optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 52–55why, one step back52 program.name('pm');53 program.command('sub', 'executable description');54 program.parse(['sub'], { from: 'user' });55Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 56why, one step back56 assert.equal(existsSpy.mock.callCount(), 0);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 57–58why, one step back57 });58Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 59–60why, one step back59 test('when script arg then search for local files', (t) => {60 const { existsSpy } = makeSpies(t, () => false);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 61why, one step back61 const program = new commander.Command();Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf
line 62why, one step back62 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawnAdd optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 63–66why, one step back63 program.name('pm');64 program.command('sub', 'executable description');65 program.parse(['node', 'script-name', 'sub']);66Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 67why, one step back67 assert.equal(existsSpy.mock.callCount() > 0, true);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 68–69why, one step back68 });69Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 70–71why, one step back70 test('when executableDir then search for local files)', (t) => {71 const { existsSpy } = makeSpies(t, () => false);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 72why, one step back72 const program = new commander.Command();Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf
line 73why, one step back73 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawnAdd optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 74–78why, one step back74 program.name('pm');75 program.executableDir(__dirname);76 program.command('sub', 'executable description');77 program.parse(['sub'], { from: 'user' });78Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 79why, one step back79 assert.equal(existsSpy.mock.callCount() > 0, true);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 80–83why, one step back80 });81 });8283 // We always use node on Windows, and don't spawn executable as the command (which may be a feature or a shortcoming!?).Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 84–86why, one step back84 describeOrSkipOnWindows(85 'subcommand command name with no matching local file (non-Windows)',86 () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 87–88why, one step back87 test('when named pm and no script arg or executableDir then spawn pm-sub as command', (t) => {88 const { spawnSpy } = makeSpies(t, () => false);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 89–92why, one step back89 const program = new commander.Command();90 program.name('pm');91 program.command('sub', 'executable description');92 program.parse(['sub'], { from: 'user' });Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 93why, one step back93Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 94why, one step back94 assert.equal(extractMockSpawnCommand(spawnSpy), 'pm-sub');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 95why, one step back95 });Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 96why, one step back96Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 97–98why, one step back97 test('when named pm and script arg then still spawn pm-sub as command', (t) => {98 const { spawnSpy } = makeSpies(t, () => false);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 99–102why, one step back99 const program = new commander.Command();100 program.name('pm');101 program.command('sub', 'executable description');102 program.parse(['node', 'script-name', 'sub']);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 103why, one step back103Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 104why, one step back104 assert.equal(extractMockSpawnCommand(spawnSpy), 'pm-sub');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 105why, one step back105 });Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 106why, one step back106Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 107–108why, one step back107 test('when no name and script arg then spawn script-sub as command', (t) => {108 const { spawnSpy } = makeSpies(t, () => false);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 109–111why, one step back109 const program = new commander.Command();110 program.command('sub', 'executable description');111 program.parse(['node', 'script.js', 'sub']);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 112why, one step back112Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 113why, one step back113 assert.equal(extractMockSpawnCommand(spawnSpy), 'script-sub');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 114why, one step back114 });Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 115why, one step back115Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 116–117why, one step back116 test('when named pm and script arg and executableFile then spawn executableFile as command', (t) => {117 const { spawnSpy } = makeSpies(t, () => false);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 118–122why, one step back118 const program = new commander.Command();119 program.command('sub', 'executable description', {120 executableFile: 'myExecutable',121 });122 program.parse(['node', 'script.js', 'sub']);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 123why, one step back123Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 124why, one step back124 assert.equal(extractMockSpawnCommand(spawnSpy), 'myExecutable');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 125–127why, one step back125 });126 },127 );Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 128–129why, one step back128129 describe('subcommand command name with matching local file', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 130why, one step back130 test('when construct with name pm and script arg then spawn local pm-sub.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 131–134why, one step back131 const program = new commander.Command('pm');132 program.command('sub', 'executable description');133134 const localPath = path.resolve(gLocalDirectory, 'pm-sub.js');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 135why, one step back135 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 136–140why, one step back136 program.parse([137 'node',138 path.resolve(gLocalDirectory, 'script.js'),139 'sub',140 ]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 141why, one step back141Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 142why, one step back142 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 143–144why, one step back143 });144Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 145why, one step back145 test('when name pm and script arg then spawn local pm-sub.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 146–150why, one step back146 const program = new commander.Command();147 program.name('pm');148 program.command('sub', 'executable description');149150 const localPath = path.resolve(gLocalDirectory, 'pm-sub.js');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 151why, one step back151 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 152–156why, one step back152 program.parse([153 'node',154 path.resolve(gLocalDirectory, 'script.js'),155 'sub',156 ]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 157why, one step back157Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 158why, one step back158 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 159–160why, one step back159 });160Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 161why, one step back161 test('when script arg then spawn local script-sub.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 162–165why, one step back162 const program = new commander.Command();163 program.command('sub', 'executable description');164165 const localPath = path.resolve(gLocalDirectory, 'script-sub.js');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 166why, one step back166 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 167–171why, one step back167 program.parse([168 'node',169 path.resolve(gLocalDirectory, 'script.js'),170 'sub',171 ]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 172why, one step back172Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 173why, one step back173 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 174–175why, one step back174 });175Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 176why, one step back176 test('when name pm and script arg and only script-sub.js then fallback to spawn local script-sub.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 177–182why, one step back177 const program = new commander.Command();178 program.name('pm');179 program.command('sub', 'executable description');180181 // Fallback for compatibility with Commander <= v8182 const localPath = path.resolve(gLocalDirectory, 'script-sub.js');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 183why, one step back183 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 184–188why, one step back184 program.parse([185 'node',186 path.resolve(gLocalDirectory, 'script.js'),187 'sub',188 ]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 189why, one step back189Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 190why, one step back190 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 191–192why, one step back191 });192Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 193why, one step back193 test('when name pm and executableDir then spawn local pm-sub.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 194–200why, one step back194 const program = new commander.Command();195 program.name('pm');196 program.command('sub', 'executable description');197198 const execDir = path.resolve(gLocalDirectory, 'exec-dir');199 program.executableDir(execDir);200 const localPath = path.resolve(execDir, 'pm-sub.js');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 201why, one step back201 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 202–203why, one step back202 program.parse(['sub'], { from: 'user' });203Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 204why, one step back204 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 205–206why, one step back205 });206Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 207why, one step back207 test('when script arg and relative executableDir then spawn relative script-sub.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 208–213why, one step back208 const program = new commander.Command();209 program.command('sub', 'executable description');210211 const execDir = 'exec-dir';212 program.executableDir(execDir);213 const localPath = path.resolve(gLocalDirectory, execDir, 'script-sub.js');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 214why, one step back214 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 215–216why, one step back215 program.parse(['node', path.resolve(gLocalDirectory, 'script'), 'sub']);216Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 217why, one step back217 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 218–219why, one step back218 });219Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 220why, one step back220 test('when script arg and absolute executableDir then spawn absolute script-sub.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 221–226why, one step back221 const program = new commander.Command();222 program.command('sub', 'executable description');223224 const execDir = path.resolve(gLocalDirectory, 'exec-dir');225 program.executableDir(execDir);226 const localPath = path.resolve(execDir, 'script-sub.js');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 227why, one step back227 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 228–232why, one step back228 program.parse([229 'node',230 path.resolve(gLocalDirectory, 'script-Dir', 'script'),231 'sub',232 ]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 233why, one step back233Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 234why, one step back234 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 235–236why, one step back235 });236Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 237why, one step back237 test('when script arg is link and and link-sub relative to link target then spawn local link-sub', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 238–242why, one step back238 const program = new commander.Command();239 program.command('sub', 'executable description');240241 const linkPath = path.resolve(gLocalDirectory, 'link', 'link');242 const scriptPath = path.resolve(gLocalDirectory, 'script', 'script.js');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 243–247why, one step back243 const scriptSubPath = path.resolve(244 gLocalDirectory,245 'script',246 'link-sub.js',247 );Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 248–251why, one step back248 t.mock.method(fs, 'realpathSync', (path) => {249 return path === linkPath ? scriptPath : linkPath;250 });251 const { spawnSpy } = makeSpies(t, (path) => path === scriptSubPath);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 252–253why, one step back252 program.parse(['node', linkPath, 'sub']);253Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 254why, one step back254 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [scriptSubPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 255–256why, one step back255 });256Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 257why, one step back257 test('when name pm and script arg and relative executableFile then spawn local exec.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 258–260why, one step back258 const program = new commander.Command('pm');259 const localPath = path.join('relative', 'exec.js');260 const absolutePath = path.resolve(gLocalDirectory, localPath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 261–263why, one step back261 program.command('sub', 'executable description', {262 executableFile: localPath,263 });Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 264why, one step back264Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 265why, one step back265 const { spawnSpy } = makeSpies(t, (path) => path === absolutePath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 266–270why, one step back266 program.parse([267 'node',268 path.resolve(gLocalDirectory, 'script.js'),269 'sub',270 ]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 271why, one step back271Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 272why, one step back272 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [absolutePath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 273–274why, one step back273 });274Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 275why, one step back275 test('when name pm and script arg and absolute executableFile then spawn local exec.js', (t) => {Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 276–277why, one step back276 const program = new commander.Command('pm');277 const localPath = path.resolve(gLocalDirectory, 'absolute', 'exec.js');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 278–280why, one step back278 program.command('sub', 'executable description', {279 executableFile: localPath,280 });Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 281why, one step back281Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 282why, one step back282 const { spawnSpy } = makeSpies(t, (path) => path === localPath);Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 283–287why, one step back283 program.parse([284 'node',285 path.resolve(gLocalDirectory, 'script.js'),286 'sub',287 ]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 288why, one step back288Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 289why, one step back289 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 290–293why, one step back290 });291 });292293 describe('search for local file', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 294–295why, one step back294 test('when script arg then search for local script-sub.js, .ts, .tsx, .mpjs, .cjs', (t) => {295 const { existsSpy } = makeSpies(t, () => false);Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
line 296why, one step back296 const program = new commander.Command();Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf
line 297why, one step back297 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawnAdd optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 298–302why, one step back298 program.command('sub', 'executable description');299 const scriptPath = path.resolve(gLocalDirectory, 'script');300 program.parse(['node', scriptPath, 'sub']);301 const sourceExt = ['.js', '.ts', '.tsx', '.mjs', '.cjs'];302 sourceExt.forEach((ext) => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 303–310why, one step back303 const expectedPath = path.resolve(gLocalDirectory, `script-sub${ext}`);304 const wasCalled = existsSpy.mock.calls.some(305 (call) => call.arguments[0] === expectedPath,306 );307 assert.equal(308 wasCalled,309 true,310 `Expected existsSpy to be called with ${expectedPath}`,Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 311why, one step back311 );Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b
lines 312–315why, one step back312 });313 });314 });315});