diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2021-03-29 18:00:44 +0300 |
---|---|---|
committer | Ruy Adorno <ruyadorno@hotmail.com> | 2021-03-29 20:52:19 +0300 |
commit | 9dd2ed5189b6f283094664e9e192cf1598ec3f79 (patch) | |
tree | 2b6ec9c0a15b013aaba73cf52c35bbd43382145c /smoke-tests | |
parent | a28f89572a708cced69cc938f877eaa969dbad9e (diff) |
fix: empty newline printed to stderr
Starting in v7.7.0 running `npm` (no args) is printing an empty newline
to stderr.
This fixes that by correctly exiting via errorHandler and avoiding
hitting the cb() never called error and adds a test to make sure we
avoid that regression moving forward.
Fixes: https://github.com/nodejs/node/pull/37678#issuecomment-808734374
Co-authored-by: Gar <gar+gh@danger.computer>
Diffstat (limited to 'smoke-tests')
-rw-r--r-- | smoke-tests/index.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/smoke-tests/index.js b/smoke-tests/index.js index 38c3ed306..2c2a1b6ab 100644 --- a/smoke-tests/index.js +++ b/smoke-tests/index.js @@ -12,6 +12,7 @@ t.cleanSnapshot = s => s.split(cwd).join('{CWD}') .split(process.cwd()).join('{CWD}') .replace(/\\+/g, '/') .replace(/\r\n/g, '\n') + .replace(/\ \(in a browser\)/g, '') // setup server const registryServer = require('./server.js') @@ -55,6 +56,19 @@ t.test('npm init', async t => { t.equal(pkg.version, '1.0.0', 'should have expected generated version') }) +t.test('npm (no args)', async t => { + const cmd = `"${process.execPath}" "${npmLocation}" --no-audit --no-update-notifier` + const cmdRes = await execAsync(cmd, { cwd: localPrefix, env }) + .catch(err => { + t.equal(err.code, 1, 'should exit with error code') + return err + }) + + t.equal(cmdRes.stderr, '', 'should have no stderr output') + t.matchSnapshot(String(cmdRes.stdout), + 'should have expected no args output') +}) + t.test('npm install prodDep@version', async t => { const cmd = `${npmBin} install abbrev@1.0.4` const cmdRes = await exec(cmd) |