Skip to content
Myr

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 file

Take 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 back
1const childProcess = require('child_process');
2const path = require('path');

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 3why, one step back
3const util = require('util');

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 4why, one step back
4const execFileAsync = util.promisify(childProcess.execFile);

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 5–6why, one step back
5
6// 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 back
7// This file does end-to-end tests actually spawning program.
8// See also command.executableSubcommand.search.test.js

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

line 9why, one step back
9

Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c

line 10why, one step back
10// Suppress false positive warnings due to use of testOrSkipOnWindows

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 11–12why, one step back
11/* eslint-disable jest/no-standalone-expect */
12

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 13–15why, one step back
13const testOrSkipOnWindows = (process.platform === 'win32') ? test.skip : test;
14const pm = path.join(__dirname, './fixtures/pm');15

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 16–17why, one step back
16test('when subcommand file missing then error', () => {
17 expect.assertions(1);

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 18why, one step back
18 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 back
19 if (process.platform === 'win32') {
20 // Get uncaught thrown error on Windows

Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12

line 21why, one step back
21 // eslint-disable-next-line jest/no-conditional-expect

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 22why, one step back
22 expect(err.stderr).toBeDefined();

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

line 23why, one step back
23 } else {

Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12

line 24why, one step back
24 // eslint-disable-next-line jest/no-conditional-expect

Update dependencies in 7.x (#1412)John Geebefore adoption469acc9

line 25why, one step back
25 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 back
26 }
27 });28});29

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

lines 30–31why, one step back
30test('when alias subcommand file missing then error', () => {
31 expect.assertions(1);

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 32why, one step back
32 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 back
33 if (process.platform === 'win32') {
34 // Get uncaught thrown error on Windows

Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12

line 35why, one step back
35 // eslint-disable-next-line jest/no-conditional-expect

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 36why, one step back
36 expect(err.stderr).toBeDefined();

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

line 37why, one step back
37 } else {

Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12

line 38why, one step back
38 // eslint-disable-next-line jest/no-conditional-expect

Update dependencies in 7.x (#1412)John Geebefore adoption469acc9

line 39why, one step back
39 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 back
40 }
41 });42});43

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 44why, one step back
44test('when subcommand file has no suffix then lookup succeeds', async() => {

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 45why, one step back
45 const { stdout } = await execFileAsync('node', [pm, 'install']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 46why, one step back
46 expect(stdout).toBe('install\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 47–48why, one step back
47});
48

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 49why, one step back
49test('when alias subcommand file has no suffix then lookup succeeds', async() => {

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 50why, one step back
50 const { stdout } = await execFileAsync('node', [pm, 'i']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 51why, one step back
51 expect(stdout).toBe('install\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 52–53why, one step back
52});
53

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 54why, one step back
54test('when subcommand target executablefile has no suffix then lookup succeeds', async() => {

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 55why, one step back
55 const { stdout } = await execFileAsync('node', [pm, 'specifyInstall']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 56why, one step back
56 expect(stdout).toBe('install\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

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

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 59why, one step back
59test('when subcommand file suffix .js then lookup succeeds', async() => {

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 60why, one step back
60 const { stdout } = await execFileAsync('node', [pm, 'publish']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 61why, one step back
61 expect(stdout).toBe('publish\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 62–63why, one step back
62});
63

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 64why, one step back
64test('when alias subcommand file suffix .js then lookup succeeds', async() => {

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 65why, one step back
65 const { stdout } = await execFileAsync('node', [pm, 'p']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 66why, one step back
66 expect(stdout).toBe('publish\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 67–68why, one step back
67});
68

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 69why, one step back
69test('when subcommand target executablefile has suffix .js then lookup succeeds', async() => {

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 70why, one step back
70 const { stdout } = await execFileAsync('node', [pm, 'specifyPublish']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 71why, one step back
71 expect(stdout).toBe('publish\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 72–73why, one step back
72});
73

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 74why, one step back
74testOrSkipOnWindows('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 back
75 const pmlink = path.join(__dirname, 'fixtures', 'pmlink');

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 76why, one step back
76 const { stdout } = await execFileAsync('node', [pmlink, 'install']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 77why, one step back
77 expect(stdout).toBe('install\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 78–79why, one step back
78});
79

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 80why, one step back
80testOrSkipOnWindows('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 back
81 const pmlink = path.join(__dirname, 'fixtures', 'another-dir', 'pm');

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 82why, one step back
82 const { stdout } = await execFileAsync('node', [pmlink, 'install']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 83why, one step back
83 expect(stdout).toBe('install\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

lines 84–85why, one step back
84});
85

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 86why, one step back
86test('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 back
87 // 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 back
88 // 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 back
90 // 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 back
91 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 back
105});
106

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 107why, one step back
107test('when subsubcommand then lookup sub-sub-command', async() => {

Merge branch 'master' into release/7.xJohn Geebefore adoption5fd6e88

line 108why, one step back
108 const { stdout } = await execFileAsync('node', [pm, 'cache', 'clear']);

Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7

line 109why, one step back
109 expect(stdout).toBe('cache-clear\n');

Combine normalize and parseoptions, and update combined option handling (#1152)John Geebefore adoption1691344

line 110why, one step back
110});