Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-11-06 22:02:01 +0300
committerisaacs <i@izs.me>2020-11-06 22:02:01 +0300
commit1d90b2747ac3c7d4f6fa1df2c23aec33c4e0d8a0 (patch)
treeb5a7da7681e56657d193691b07dcb60a3baebe6e /test/lib/run-script.js
parenta73dc6737c2ab6fb81aa7912a59265700713775f (diff)
run: default the 'start' script when server.js present
Diffstat (limited to 'test/lib/run-script.js')
-rw-r--r--test/lib/run-script.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/test/lib/run-script.js b/test/lib/run-script.js
index 7a034aff0..7ddb6ff6f 100644
--- a/test/lib/run-script.js
+++ b/test/lib/run-script.js
@@ -25,9 +25,11 @@ const output = []
const npmlog = { level: 'warn' }
const getRS = windows => requireInject('../../lib/run-script.js', {
- '@npmcli/run-script': async opts => {
+ '@npmcli/run-script': Object.assign(async opts => {
RUN_SCRIPTS.push(opts)
- },
+ }, {
+ isServerPackage: require('@npmcli/run-script').isServerPackage,
+ }),
npmlog,
'../../lib/npm.js': npm,
'../../lib/utils/is-windows-shell.js': windows,
@@ -90,10 +92,29 @@ t.test('fail if no package.json', async t => {
await runScript(['test'], er => t.match(er, { code: 'ENOENT' }))
})
-t.test('default env and restart scripts', async t => {
+t.test('default env, start, and restart scripts', async t => {
npm.localPrefix = t.testdir({
- 'package.json': JSON.stringify({ name: 'x', version: '1.2.3' })
+ 'package.json': JSON.stringify({ name: 'x', version: '1.2.3' }),
+ 'server.js': 'console.log("hello, world")',
+ })
+
+ await runScript(['start'], er => {
+ if (er) {
+ throw er
+ }
+ t.match(RUN_SCRIPTS, [
+ {
+ path: npm.localPrefix,
+ args: [],
+ scriptShell: undefined,
+ stdio: 'inherit',
+ stdioString: true,
+ pkg: { name: 'x', version: '1.2.3', _id: 'x@1.2.3', scripts: {}},
+ event: 'start'
+ }
+ ])
})
+ RUN_SCRIPTS.length = 0
await runScript(['env'], er => {
if (er) {