command.executableSubcommand.lookup.test.js
This file
Path
tests/command.executableSubcommand.lookup.test.js
110 lines · 4.4 KiB · JavaScript
Last changed by
Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
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–6why, one step back56// Calling node explicitly so pm works without file suffix cross-platform.Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
lines 7–8why, one step back7// This file does end-to-end tests actually spawning program.8// See also command.executableSubcommand.search.test.jsCombine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 9why, one step back9Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
line 10why, one step back10// Suppress false positive warnings due to use of testOrSkipOnWindowsUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 11–12why, one step back11/* eslint-disable jest/no-standalone-expect */12Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 13–15why, one step back13const testOrSkipOnWindows = (process.platform === 'win32') ? test.skip : test;14const pm = path.join(__dirname, './fixtures/pm');15Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 16–17why, one step back16test('when subcommand file missing then error', () => {17 expect.assertions(1);Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 18why, one step back18 return execFileAsync('node', [pm, 'list']).catch((err) => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 19–20why, one step back19 if (process.platform === 'win32') {20 // Get uncaught thrown error on WindowsMerge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 21why, one step back21 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 22why, one step back22 expect(err.stderr).toBeDefined();Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 23why, one step back23 } else {Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 24why, one step back24 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies in 7.x (#1412)John Geebefore adoption469acc9
line 25why, one step back25 expect(err.stderr).toMatch(/Error: 'pm-list' does not exist/);Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 26–29why, one step back26 }27 });28});29Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 30–31why, one step back30test('when alias subcommand file missing then error', () => {31 expect.assertions(1);Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 32why, one step back32 return execFileAsync('node', [pm, 'lst']).catch((err) => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 33–34why, one step back33 if (process.platform === 'win32') {34 // Get uncaught thrown error on WindowsMerge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 35why, one step back35 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 36why, one step back36 expect(err.stderr).toBeDefined();Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 37why, one step back37 } else {Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 38why, one step back38 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies in 7.x (#1412)John Geebefore adoption469acc9
line 39why, one step back39 expect(err.stderr).toMatch(/Error: 'pm-list' does not exist/);Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 40–43why, one step back40 }41 });42});43Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 44why, one step back44test('when subcommand file has no suffix then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 45why, one step back45 const { stdout } = await execFileAsync('node', [pm, 'install']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 46why, one step back46 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 47–48why, one step back47});48Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 49why, one step back49test('when alias subcommand file has no suffix then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 50why, one step back50 const { stdout } = await execFileAsync('node', [pm, 'i']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 51why, one step back51 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 52–53why, one step back52});53Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 54why, one step back54test('when subcommand target executablefile has no suffix then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 55why, one step back55 const { stdout } = await execFileAsync('node', [pm, 'specifyInstall']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 56why, one step back56 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 57–58why, one step back57});58Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 59why, one step back59test('when subcommand file suffix .js then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 60why, one step back60 const { stdout } = await execFileAsync('node', [pm, 'publish']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 61why, one step back61 expect(stdout).toBe('publish\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 62–63why, one step back62});63Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 64why, one step back64test('when alias subcommand file suffix .js then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 65why, one step back65 const { stdout } = await execFileAsync('node', [pm, 'p']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 66why, one step back66 expect(stdout).toBe('publish\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 67–68why, one step back67});68Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 69why, one step back69test('when subcommand target executablefile has suffix .js then lookup succeeds', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 70why, one step back70 const { stdout } = await execFileAsync('node', [pm, 'specifyPublish']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 71why, one step back71 expect(stdout).toBe('publish\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 72–73why, one step back72});73Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 74why, one step back74testOrSkipOnWindows('when subcommand file is symlink then lookup succeeds', async() => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 75why, one step back75 const pmlink = path.join(__dirname, 'fixtures', 'pmlink');Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 76why, one step back76 const { stdout } = await execFileAsync('node', [pmlink, 'install']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 77why, one step back77 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 78–79why, one step back78});79Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 80why, one step back80testOrSkipOnWindows('when subcommand file is double symlink then lookup succeeds', async() => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 81why, one step back81 const pmlink = path.join(__dirname, 'fixtures', 'another-dir', 'pm');Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 82why, one step back82 const { stdout } = await execFileAsync('node', [pmlink, 'install']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 83why, one step back83 expect(stdout).toBe('install\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 84–85why, one step back84});85Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 86why, one step back86test('when subcommand suffix is .ts then lookup succeeds', async() => {Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 87why, one step back87 // 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 88–89why, one step back88 // The subcommand is both plain JavaScript code for this test.89 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 90why, one step back90 // 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 91–104why, one step back91 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-ts']);92 expect(stdout).toBe('found .ts\n');93});9495test('when subcommand suffix is .cjs then lookup succeeds', async() => {96 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');97 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-cjs']);98 expect(stdout).toBe('found .cjs\n');99});100101test('when subcommand suffix is .mjs then lookup succeeds', async() => {102 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');103 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-mjs']);104 expect(stdout).toBe('found .mjs\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
lines 105–106why, one step back105});106Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 107why, one step back107test('when subsubcommand then lookup sub-sub-command', async() => {Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88
line 108why, one step back108 const { stdout } = await execFileAsync('node', [pm, 'cache', 'clear']);Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 109why, one step back109 expect(stdout).toBe('cache-clear\n');Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344
line 110why, one step back110});