diff --git a/workspaces/libnpmexec/lib/run-script.js b/workspaces/libnpmexec/lib/run-script.js index 57dacf4645d6b..f41af91dfe8bf 100644 --- a/workspaces/libnpmexec/lib/run-script.js +++ b/workspaces/libnpmexec/lib/run-script.js @@ -32,9 +32,7 @@ const run = async ({ }, } - if (stdio === 'inherit') { - npmlog.disableProgress() - } + npmlog.disableProgress() try { if (script === scriptShell) { diff --git a/workspaces/libnpmexec/test/index.js b/workspaces/libnpmexec/test/index.js index 008560efc7018..5bc8d7677eecd 100644 --- a/workspaces/libnpmexec/test/index.js +++ b/workspaces/libnpmexec/test/index.js @@ -14,3 +14,41 @@ t.test('no args', async t => { await exec() }) + +t.test('stdio value', t => { + t.test('stdio default value', t => { + const libexec = t.mock('../lib/index.js', { + '../lib/run-script.js': (opt) => { + t.equal(opt.stdio, 'inherit', 'should use expected stdio value') + }, + npmlog: { + disableProgress () { + t.ok('should disable progress') + }, + enableProgress () { + t.ok('should enable progress') + }, + }, + }) + libexec({ args: [], runPath: t.testDirName }) + }) + + t.test('stdio custom value', t => { + const libexec = t.mock('../lib/index.js', { + '../lib/run-script.js': (opt) => { + t.equal(opt.stdio, 'pipe', 'should use expected stdio value') + }, + npmlog: { + disableProgress () { + t.ok('should disable progress') + }, + enableProgress () { + t.fail('should not enable progress') + }, + }, + }) + libexec({ args: [], stdio: 'pipe', runPath: t.testDirName }) + }) + + t.end() +})