| @@ -25,9 +25,11 @@ const output = [] |
|
|
| 25 |
25 |
|
| 26 |
26 |
const npmlog = { level: 'warn' } |
| 27 |
27 |
const getRS = windows => requireInject('../../lib/run-script.js', { |
| 28 |
|
-'@npmcli/run-script': async opts => { |
|
28 |
+'@npmcli/run-script': Object.assign(async opts => { |
| 29 |
29 |
RUN_SCRIPTS.push(opts) |
| 30 |
|
-}, |
|
30 |
+}, { |
|
31 |
+isServerPackage: require('@npmcli/run-script').isServerPackage, |
|
32 |
+}), |
| 31 |
33 |
npmlog, |
| 32 |
34 |
'../../lib/npm.js': npm, |
| 33 |
35 |
'../../lib/utils/is-windows-shell.js': windows, |
| @@ -90,10 +92,29 @@ t.test('fail if no package.json', async t => { |
|
|
| 90 |
92 |
await runScript(['test'], er => t.match(er, { code: 'ENOENT' })) |
| 91 |
93 |
}) |
| 92 |
94 |
|
| 93 |
|
-t.test('default env and restart scripts', async t => { |
|
95 |
+t.test('default env, start, and restart scripts', async t => { |
| 94 |
96 |
npm.localPrefix = t.testdir({ |
| 95 |
|
-'package.json': JSON.stringify({ name: 'x', version: '1.2.3' }) |
|
97 |
+'package.json': JSON.stringify({ name: 'x', version: '1.2.3' }), |
|
98 |
+'server.js': 'console.log("hello, world")', |
|
99 |
+}) |
|
100 |
+ |
|
101 |
+await runScript(['start'], er => { |
|
102 |
+if (er) { |
|
103 |
+throw er |
|
104 |
+} |
|
105 |
+t.match(RUN_SCRIPTS, [ |
|
106 |
+{ |
|
107 |
+path: npm.localPrefix, |
|
108 |
+args: [], |
|
109 |
+scriptShell: undefined, |
|
110 |
+stdio: 'inherit', |
|
111 |
+stdioString: true, |
|
112 |
+pkg: { name: 'x', version: '1.2.3', _id: 'x@1.2.3', scripts: {}}, |
|
113 |
+event: 'start' |
|
114 |
+} |
|
115 |
+]) |
| 96 |
116 |
}) |
|
117 |
+RUN_SCRIPTS.length = 0 |
| 97 |
118 |
|
| 98 |
119 |
await runScript(['env'], er => { |
| 99 |
120 |
if (er) { |