Skip to content
Myr

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 file

Take 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 back
1const 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 back
5const { 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 back
7
8// 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.12

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 13–21why, one step back
13function 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 back
22}
23

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 24–25why, one step back
24function 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 back
26 // 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 back
27 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 back
29}
30

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 31–32why, one step back
31const 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 back
33
34describe('search for subcommand', () => {

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 35–36why, one step back
35 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 back
37 return {
38 on: () => {},

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 39why, one step back
39 killed: true,

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 40–41why, one step back
40 };
41 });

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 42–44why, one step back
42 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 back
45

Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf

line 46why, one step back
46 // 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 back
47 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 back
48 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 back
50 const program = new commander.Command();

Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf

line 51why, one step back
51 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 52–55why, one step back
52 program.name('pm');
53 program.command('sub', 'executable description');54 program.parse(['sub'], { from: 'user' });55

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 56why, one step back
56 assert.equal(existsSpy.mock.callCount(), 0);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 57–58why, one step back
57 });
58

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 59–60why, one step back
59 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 back
61 const program = new commander.Command();

Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf

line 62why, one step back
62 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 63–66why, one step back
63 program.name('pm');
64 program.command('sub', 'executable description');65 program.parse(['node', 'script-name', 'sub']);66

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 67why, one step back
67 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 back
68 });
69

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 70–71why, one step back
70 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 back
72 const program = new commander.Command();

Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf

line 73why, one step back
73 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 74–78why, one step back
74 program.name('pm');
75 program.executableDir(__dirname);76 program.command('sub', 'executable description');77 program.parse(['sub'], { from: 'user' });78

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 79why, one step back
79 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 back
80 });
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 back
84 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 back
87 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 back
89 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 back
93

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 94why, one step back
94 assert.equal(extractMockSpawnCommand(spawnSpy), 'pm-sub');

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 95why, one step back
95 });

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

line 96why, one step back
96

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 97–98why, one step back
97 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 back
99 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 back
103

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 104why, one step back
104 assert.equal(extractMockSpawnCommand(spawnSpy), 'pm-sub');

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 105why, one step back
105 });

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

line 106why, one step back
106

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 107–108why, one step back
107 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 back
109 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 back
112

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 113why, one step back
113 assert.equal(extractMockSpawnCommand(spawnSpy), 'script-sub');

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 114why, one step back
114 });

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

line 115why, one step back
115

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 116–117why, one step back
116 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 back
118 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 back
123

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 124why, one step back
124 assert.equal(extractMockSpawnCommand(spawnSpy), 'myExecutable');

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 125–127why, one step back
125 });
126 },127 );

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 128–129why, one step back
128
129 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 back
130 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 back
131 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 back
135 const { spawnSpy } = makeSpies(t, (path) => path === localPath);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 136–140why, one step back
136 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 back
141

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 142why, one step back
142 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 143–144why, one step back
143 });
144

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 145why, one step back
145 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 back
146 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 back
151 const { spawnSpy } = makeSpies(t, (path) => path === localPath);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 152–156why, one step back
152 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 back
157

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 158why, one step back
158 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 159–160why, one step back
159 });
160

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 161why, one step back
161 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 back
162 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 back
166 const { spawnSpy } = makeSpies(t, (path) => path === localPath);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 167–171why, one step back
167 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 back
172

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 173why, one step back
173 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 174–175why, one step back
174 });
175

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 176why, one step back
176 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 back
177 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 back
183 const { spawnSpy } = makeSpies(t, (path) => path === localPath);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 184–188why, one step back
184 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 back
189

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 190why, one step back
190 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 191–192why, one step back
191 });
192

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 193why, one step back
193 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 back
194 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 back
201 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 back
202 program.parse(['sub'], { from: 'user' });
203

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 204why, one step back
204 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 205–206why, one step back
205 });
206

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 207why, one step back
207 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 back
208 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 back
214 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 back
215 program.parse(['node', path.resolve(gLocalDirectory, 'script'), 'sub']);
216

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 217why, one step back
217 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 218–219why, one step back
218 });
219

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 220why, one step back
220 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 back
221 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 back
227 const { spawnSpy } = makeSpies(t, (path) => path === localPath);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 228–232why, one step back
228 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 back
233

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 234why, one step back
234 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 235–236why, one step back
235 });
236

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 237why, one step back
237 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 back
238 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 back
243 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 back
248 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 back
252 program.parse(['node', linkPath, 'sub']);
253

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 254why, one step back
254 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [scriptSubPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 255–256why, one step back
255 });
256

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 257why, one step back
257 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 back
258 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 back
261 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 back
264

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 265why, one step back
265 const { spawnSpy } = makeSpies(t, (path) => path === absolutePath);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 266–270why, one step back
266 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 back
271

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 272why, one step back
272 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [absolutePath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 273–274why, one step back
273 });
274

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 275why, one step back
275 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 back
276 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 back
278 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 back
281

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 282why, one step back
282 const { spawnSpy } = makeSpies(t, (path) => path === localPath);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 283–287why, one step back
283 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 back
288

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 289why, one step back
289 assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 290–293why, one step back
290 });
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 back
294 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 back
296 const program = new commander.Command();

Add informative message for missing executable on Windows (#2291)John Geebefore adoptiona8ef5cf

line 297why, one step back
297 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 298–302why, one step back
298 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 back
303 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 back
311 );

Add optional summary for short form of subcommand description. (#1726)John Geebefore adoptioncc2db5b

lines 312–315why, one step back
312 });
313 });314 });315});