diff options
author | nlf <quitlahok@gmail.com> | 2020-10-26 21:10:23 +0300 |
---|---|---|
committer | nlf <quitlahok@gmail.com> | 2020-10-27 21:35:34 +0300 |
commit | 46c7f792ab16dd0b091e1ad6d37de860c8885883 (patch) | |
tree | e1ba6afa757d1c9f18299efdae2cad9aa6fb2dcf /test/lib/exec.js | |
parent | d8ac70752a002f7b89218bc3b728ead26258488f (diff) |
skip the prompt when in a known ci environment
PR-URL: https://github.com/npm/cli/pull/2047
Credit: @nlf
Close: #2047
Reviewed-by: @ruyadorno
Diffstat (limited to 'test/lib/exec.js')
-rw-r--r-- | test/lib/exec.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/lib/exec.js b/test/lib/exec.js index ca8c2c1e7..97da01140 100644 --- a/test/lib/exec.js +++ b/test/lib/exec.js @@ -80,9 +80,12 @@ const read = (options, cb) => { const PATH = require('../../lib/utils/path.js') +let CI_NAME = 'travis-ci' + const exec = requireInject('../../lib/exec.js', { '@npmcli/arborist': Arborist, '@npmcli/run-script': runScript, + '@npmcli/ci-detect': () => CI_NAME, '../../lib/npm.js': npm, pacote, read, @@ -531,9 +534,11 @@ t.test('prompt when installs are needed if not already present and shell is a TT t.teardown(() => { process.stdout.isTTY = stdoutTTY process.stdin.isTTY = stdinTTY + CI_NAME = 'travis-ci' }) process.stdout.isTTY = true process.stdin.isTTY = true + CI_NAME = false const packages = ['foo', 'bar'] READ_RESULT = 'yolo' @@ -598,9 +603,11 @@ t.test('skip prompt when installs are needed if not already present and shell is t.teardown(() => { process.stdout.isTTY = stdoutTTY process.stdin.isTTY = stdinTTY + CI_NAME = 'travis-ci' }) process.stdout.isTTY = false process.stdin.isTTY = false + CI_NAME = false const packages = ['foo', 'bar'] READ_RESULT = 'yolo' @@ -663,9 +670,11 @@ t.test('skip prompt when installs are needed if not already present and shell is t.teardown(() => { process.stdout.isTTY = stdoutTTY process.stdin.isTTY = stdinTTY + CI_NAME = 'travis-ci' }) process.stdout.isTTY = false process.stdin.isTTY = false + CI_NAME = false const packages = ['foo'] READ_RESULT = 'yolo' @@ -720,9 +729,11 @@ t.test('abort if prompt rejected', async t => { t.teardown(() => { process.stdout.isTTY = stdoutTTY process.stdin.isTTY = stdinTTY + CI_NAME = 'travis-ci' }) process.stdout.isTTY = true process.stdin.isTTY = true + CI_NAME = false const packages = ['foo', 'bar'] READ_RESULT = 'no, why would I want such a thing??' @@ -776,9 +787,11 @@ t.test('abort if prompt false', async t => { t.teardown(() => { process.stdout.isTTY = stdoutTTY process.stdin.isTTY = stdinTTY + CI_NAME = 'travis-ci' }) process.stdout.isTTY = true process.stdin.isTTY = true + CI_NAME = false const packages = ['foo', 'bar'] READ_ERROR = 'canceled' @@ -832,9 +845,11 @@ t.test('abort if -n provided', async t => { t.teardown(() => { process.stdout.isTTY = stdoutTTY process.stdin.isTTY = stdinTTY + CI_NAME = 'travis-ci' }) process.stdout.isTTY = true process.stdin.isTTY = true + CI_NAME = false const packages = ['foo', 'bar'] |