Skip to content

Commit 8e08311

Browse files
authored
fix: add arguments back to the logged banner (#102)
1 parent 82ef491 commit 8e08311

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/run-script-pkg.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ const signalManager = require('./signal-manager.js')
66
const isServerPackage = require('./is-server-package.js')
77

88
// you wouldn't like me when I'm angry...
9-
const bruce = (id, event, cmd) =>
10-
`\n> ${id ? id + ' ' : ''}${event}\n> ${cmd.trim().replace(/\n/g, '\n> ')}\n`
9+
const bruce = (id, event, cmd, args) => {
10+
let banner = id
11+
? `\n> ${id} ${event}\n`
12+
: `\n> ${event}\n`
13+
banner += `> ${cmd.trim().replace(/\n/g, '\n> ')}`
14+
if (args.length) {
15+
banner += ` ${args.join(' ')}`
16+
}
17+
banner += '\n'
18+
return banner
19+
}
1120

1221
const runScriptPkg = async options => {
1322
const {
@@ -52,7 +61,7 @@ const runScriptPkg = async options => {
5261

5362
if (stdio === 'inherit' && banner !== false) {
5463
// we're dumping to the parent's stdout, so print the banner
55-
console.log(bruce(pkg._id, event, cmd))
64+
console.log(bruce(pkg._id, event, cmd, args))
5665
}
5766

5867
const [spawnShell, spawnArgs, spawnOpts] = makeSpawnArgs({

test/run-script-pkg.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ t.test('do the banner with no pkgid', t => {
239239
},
240240
stdio: 'inherit',
241241
cmd: 'bar',
242+
args: ['baz', 'buzz'],
242243
pkg: {
243244
scripts: {},
244245
},
@@ -247,19 +248,19 @@ t.test('do the banner with no pkgid', t => {
247248
event: 'foo',
248249
path: 'path',
249250
scriptShell: 'sh',
250-
args: [],
251251
binPaths: false,
252252
env: {
253253
environ: 'value',
254254
},
255255
stdio: 'inherit',
256256
cmd: 'bar',
257+
args: ['baz', 'buzz'],
257258
}, {
258259
event: 'foo',
259260
script: 'bar',
260261
path: 'path',
261262
pkgid: undefined,
262-
}])).then(() => t.strictSame(logs, [['\n> foo\n> bar\n']]))
263+
}])).then(() => t.strictSame(logs, [['\n> foo\n> bar baz buzz\n']]))
263264
})
264265

265266
t.test('pkg has foo script', t => runScriptPkg({

0 commit comments

Comments
 (0)