command.executableSubcommand.lookup.test.js
This file
Path
tests/command.executableSubcommand.lookup.test.js
108 lines · 4.3 KiB · JavaScript
Last changed by
Add cjs to list of expected node script extensions (#1449)John Geebefore adoptiona28a89b
History of this fileTake it
The walk stopped after 200 commits: lines older than 1691344 point at it.
Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 1–2why, one step back1const childProcess = require('child_process');2const path = require('path');Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 3why, one step back3const util = require('util');Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 4why, one step back4const execFileAsync = util.promisify(childProcess.execFile);Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 5–7why, one step back56// Calling node explicitly so pm works without file suffix cross-platform.7Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 8–10why, one step back8// Get false positives due to use of testOrSkipOnWindows9/* eslint-disable jest/no-standalone-expect */10Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 11–13why, one step back11const testOrSkipOnWindows = (process.platform === 'win32') ? test.skip : test;12const pm = path.join(__dirname, './fixtures/pm');13Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 14–15why, one step back14test('when subcommand file missing then error', () => {15 expect.assertions(1);Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 16why, one step back16 return execFileAsync('node', [pm, 'list']).catch((err) => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 17–18why, one step back17 if (process.platform === 'win32') {18 // Get uncaught thrown error on WindowsMerge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 19why, one step back19 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 20why, one step back20 expect(err.stderr).toBeDefined();Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 21why, one step back21 } else {Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 22why, one step back22 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies in 7.x (#1412)John Geebefore adoption469acc9
line 23why, one step back23 expect(err.stderr).toMatch(/Error: 'pm-list' does not exist/);Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 24–27why, one step back24 }25 });26});27Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 28–29why, one step back28test('when alias subcommand file missing then error', () => {29 expect.assertions(1);Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 30why, one step back30 return execFileAsync('node', [pm, 'lst']).catch((err) => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 31–32why, one step back31 if (process.platform === 'win32') {32 // Get uncaught thrown error on WindowsMerge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 33why, one step back33 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 34why, one step back34 expect(err.stderr).toBeDefined();Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 35why, one step back35 } else {Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 36why, one step back36 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies in 7.x (#1412)John Geebefore adoption469acc9
line 37why, one step back37 expect(err.stderr).toMatch(/Error: 'pm-list' does not exist/);Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 38–41why, one step back38 }39 });40});41Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 42why, one step back42test('when subcommand file has no suffix then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 43why, one step back43 const { stdout } = await execFileAsync('node', [pm, 'install']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 44why, one step back44 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 45–46why, one step back45});46Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 47why, one step back47test('when alias subcommand file has no suffix then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 48why, one step back48 const { stdout } = await execFileAsync('node', [pm, 'i']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 49why, one step back49 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 50–51why, one step back50});51Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 52why, one step back52test('when subcommand target executablefile has no suffix then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 53why, one step back53 const { stdout } = await execFileAsync('node', [pm, 'specifyInstall']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 54why, one step back54 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 55–56why, one step back55});56Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 57why, one step back57test('when subcommand file suffix .js then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 58why, one step back58 const { stdout } = await execFileAsync('node', [pm, 'publish']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 59why, one step back59 expect(stdout).toBe('publish\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 60–61why, one step back60});61Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 62why, one step back62test('when alias subcommand file suffix .js then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 63why, one step back63 const { stdout } = await execFileAsync('node', [pm, 'p']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 64why, one step back64 expect(stdout).toBe('publish\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 65–66why, one step back65});66Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 67why, one step back67test('when subcommand target executablefile has suffix .js then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 68why, one step back68 const { stdout } = await execFileAsync('node', [pm, 'specifyPublish']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 69why, one step back69 expect(stdout).toBe('publish\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 70–71why, one step back70});71Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 72why, one step back72testOrSkipOnWindows('when subcommand file is symlink then lookup succeeds', async() => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 73why, one step back73 const pmlink = path.join(__dirname, 'fixtures', 'pmlink');Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 74why, one step back74 const { stdout } = await execFileAsync('node', [pmlink, 'install']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 75why, one step back75 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 76–77why, one step back76});77Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 78why, one step back78testOrSkipOnWindows('when subcommand file is double symlink then lookup succeeds', async() => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 79why, one step back79 const pmlink = path.join(__dirname, 'fixtures', 'another-dir', 'pm');Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 80why, one step back80 const { stdout } = await execFileAsync('node', [pmlink, 'install']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 81why, one step back81 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 82–83why, one step back82});83Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 84why, one step back84test('when subcommand suffix is .ts then lookup succeeds', async() => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 85why, one step back85 // We support looking for ts files for ts-node in particular, but don't need to test ts-node itself.Add cjs to list of expected node script extensions (#1449)John Geebefore adoptiona28a89b
lines 86–87why, one step back86 // The subcommand is both plain JavaScript code for this test.87 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 88why, one step back88 // childProcess.execFile('node', ['-r', 'ts-node/register', binLinkTs, 'install'], function(_error, stdout, stderr) {Add cjs to list of expected node script extensions (#1449)John Geebefore adoptiona28a89b
lines 89–102why, one step back89 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-ts']);90 expect(stdout).toBe('found .ts\n');91});9293test('when subcommand suffix is .cjs then lookup succeeds', async() => {94 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');95 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-cjs']);96 expect(stdout).toBe('found .cjs\n');97});9899test('when subcommand suffix is .mjs then lookup succeeds', async() => {100 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');101 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-mjs']);102 expect(stdout).toBe('found .mjs\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 103–104why, one step back103});104Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 105why, one step back105test('when subsubcommand then lookup sub-sub-command', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 106why, one step back106 const { stdout } = await execFileAsync('node', [pm, 'cache', 'clear']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 107why, one step back107 expect(stdout).toBe('cache-clear\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 108why, one step back108});