diff options
author | Luke Karrys <luke@lukekarrys.com> | 2022-02-22 00:33:59 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-02-24 02:58:59 +0300 |
commit | 55e9ef01f1ee6a71489b32b31d17d2cbdc2d1a64 (patch) | |
tree | cb578f3a86a5d4fecd2b32f1dc04ed7e13496ff8 /workspaces | |
parent | eef16c18aacfbfed8bcfc72407d2a1b0c5ea00bc (diff) |
chore(libnpmexec): remove log option
BREAKING CHANGE: this drops support for the `log` property
Diffstat (limited to 'workspaces')
-rw-r--r-- | workspaces/libnpmexec/README.md | 1 | ||||
-rw-r--r-- | workspaces/libnpmexec/lib/index.js | 9 | ||||
-rw-r--r-- | workspaces/libnpmexec/lib/run-script.js | 11 | ||||
-rw-r--r-- | workspaces/libnpmexec/test/index.js | 9 | ||||
-rw-r--r-- | workspaces/libnpmexec/test/run-script.js | 44 |
5 files changed, 31 insertions, 43 deletions
diff --git a/workspaces/libnpmexec/README.md b/workspaces/libnpmexec/README.md index a48552714..74d6f5211 100644 --- a/workspaces/libnpmexec/README.md +++ b/workspaces/libnpmexec/README.md @@ -35,7 +35,6 @@ await libexec({ - `color`: Output should use color? **Boolean**, defaults to `false` - `localBin`: Location to the `node_modules/.bin` folder of the local project to start scanning for bin files **String**, defaults to `./node_modules/.bin`. **libexec** will walk up the directory structure looking for `node_modules/.bin` folders in parent folders that might satisfy the current `arg` and will use that bin if found. - `locationMsg`: Overrides "at location" message when entering interactive mode **String** - - `log`: Sets an optional logger **Object**, defaults to `proc-log` module usage. - `globalBin`: Location to the global space bin folder, same as: `$(npm bin -g)` **String**, defaults to empty string. - `output`: A function to print output to **Function** - `packages`: A list of packages to be used (possibly fetch from the registry) **Array<String>**, defaults to `[]` diff --git a/workspaces/libnpmexec/lib/index.js b/workspaces/libnpmexec/lib/index.js index facafb035..3c7be1149 100644 --- a/workspaces/libnpmexec/lib/index.js +++ b/workspaces/libnpmexec/lib/index.js @@ -4,7 +4,8 @@ const read = promisify(require('read')) const Arborist = require('@npmcli/arborist') const ciDetect = require('@npmcli/ci-detect') -const logger = require('proc-log') +const log = require('proc-log') +const npmlog = require('npmlog') const mkdirp = require('mkdirp-infer-owner') const npa = require('npm-package-arg') const pacote = require('pacote') @@ -39,7 +40,6 @@ const exec = async (opts) => { yes = undefined, ...flatOptions } = opts - const log = flatOptions.log || logger // dereferences values because we manipulate it later const packages = [..._packages] @@ -50,7 +50,6 @@ const exec = async (opts) => { color, flatOptions, locationMsg, - log, output, path, pathArr, @@ -169,9 +168,7 @@ const exec = async (opts) => { const prompt = `Need to install the following packages:\n${ addList }Ok to proceed? ` - if (typeof log.clearProgress === 'function') { - log.clearProgress() - } + npmlog.clearProgress() const confirm = await read({ prompt, default: 'y' }) if (confirm.trim().toLowerCase().charAt(0) !== 'y') { throw new Error('canceled') diff --git a/workspaces/libnpmexec/lib/run-script.js b/workspaces/libnpmexec/lib/run-script.js index 851f5c60b..97543e6ff 100644 --- a/workspaces/libnpmexec/lib/run-script.js +++ b/workspaces/libnpmexec/lib/run-script.js @@ -4,6 +4,8 @@ const chalk = require('chalk') const ciDetect = require('@npmcli/ci-detect') const runScript = require('@npmcli/run-script') const readPackageJson = require('read-package-json-fast') +const npmlog = require('npmlog') +const log = require('proc-log') const noTTY = require('./no-tty.js') const nocolor = { @@ -18,7 +20,6 @@ const run = async ({ color, flatOptions, locationMsg, - log, output = () => {}, path, pathArr, @@ -41,9 +42,7 @@ const run = async ({ }, } - if (log && log.disableProgress) { - log.disableProgress() - } + npmlog.disableProgress() try { if (script === scriptShell) { @@ -80,9 +79,7 @@ const run = async ({ stdio: 'inherit', }) } finally { - if (log && log.enableProgress) { - log.enableProgress() - } + npmlog.enableProgress() } } diff --git a/workspaces/libnpmexec/test/index.js b/workspaces/libnpmexec/test/index.js index cbd3eda72..e44bc00c7 100644 --- a/workspaces/libnpmexec/test/index.js +++ b/workspaces/libnpmexec/test/index.js @@ -336,10 +336,12 @@ t.test('prompt, accepts', async t => { t.test('with clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': { + npmlog: { clearProgress () { t.ok(true, 'should call clearProgress function') }, + disableProgress () {}, + enableProgress () {}, }, read (opts, cb) { cb(null, 'y') @@ -365,7 +367,6 @@ t.test('prompt, accepts', async t => { t.test('without clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': {}, read (opts, cb) { cb(null, 'y') }, @@ -401,10 +402,11 @@ t.test('prompt, refuses', async t => { t.test('with clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': { + npmlog: { clearProgress () { t.ok(true, 'should call clearProgress function') }, + disableProgess () {}, }, read (opts, cb) { cb(null, 'n') @@ -439,7 +441,6 @@ t.test('prompt, refuses', async t => { t.test('without clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': {}, read (opts, cb) { cb(null, 'n') }, diff --git a/workspaces/libnpmexec/test/run-script.js b/workspaces/libnpmexec/test/run-script.js index c86e8e151..0b97a72ac 100644 --- a/workspaces/libnpmexec/test/run-script.js +++ b/workspaces/libnpmexec/test/run-script.js @@ -4,9 +4,6 @@ const baseOpts = { args: [], call: '', color: false, - log: { - warn () {}, - }, path: '', pathArr: [''], runPath: '', @@ -29,20 +26,18 @@ t.test('disable, enable log progress', t => { t.ok('should call run-script') }, '../lib/no-tty.js': () => false, - }) - const log = { - ...baseOpts.log, - disableProgress () { - t.ok('should disable progress') - }, - enableProgress () { - t.ok('should enable progress') + npmlog: { + disableProgress () { + t.ok('should disable progress') + }, + enableProgress () { + t.ok('should enable progress') + }, }, - } + }) runScript({ ...baseOpts, - log, path, }) }) @@ -139,18 +134,17 @@ t.test('ci env', t => { throw new Error('should not call run-script') }, '../lib/no-tty.js': () => false, - }) - const log = { - ...baseOpts.log, - warn (title, msg) { - t.equal(title, 'exec', 'should have expected title') - t.equal( - msg, - 'Interactive mode disabled in CI environment', - 'should have expected ci environment message' - ) + 'proc-log': { + warn (title, msg) { + t.equal(title, 'exec', 'should have expected title') + t.equal( + msg, + 'Interactive mode disabled in CI environment', + 'should have expected ci environment message' + ) + }, }, - } + }) - runScript({ ...baseOpts, log }) + runScript({ ...baseOpts }) }) |