diff options
author | Gar <gar+gh@danger.computer> | 2021-10-08 04:40:03 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-11-04 00:04:22 +0300 |
commit | 8ffeb71dfb248b4a76744bd06cd4d6100f17c8ae (patch) | |
tree | b44d12a79dff3afe0c92df6f6c0219f6d91ad471 /test/lib/utils/exit-handler.js | |
parent | 85d59191cf681eabd8827ca58f925c1063776f61 (diff) |
chore: refactor commands
This is the first phase of refactoring the internal structure of the npm
commands to set us up for future changes. This iteration changes the
function signature of `exec` for all the commands to be a async (no more
callbacks), and also groups all the commands into their own
subdirectory.
It also removes the Proxy `npm.commands` object, in favor of an
`npm.cmd` and `npm.exec` function that breaks up the two things that
proxy was doing. Namely, getting to the attributes of a given command
(`npm.cmd` now does this), and actually running the command `npm.exec`
does this.
PR-URL: https://github.com/npm/cli/pull/3959
Credit: @wraithgar
Close: #3959
Reviewed-by: @lukekarrys
Diffstat (limited to 'test/lib/utils/exit-handler.js')
-rw-r--r-- | test/lib/utils/exit-handler.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test/lib/utils/exit-handler.js b/test/lib/utils/exit-handler.js index c88a1aef6..f74938750 100644 --- a/test/lib/utils/exit-handler.js +++ b/test/lib/utils/exit-handler.js @@ -26,10 +26,14 @@ const cacheFolder = t.testdir({}) const logFile = path.resolve(cacheFolder, '_logs', 'expecteddate-debug.log') const timingFile = path.resolve(cacheFolder, '_timing.json') -const { npm } = mockNpm(t) +const { Npm } = mockNpm(t, { + '../../package.json': { + version: '1.0.0', + }, +}) +const npm = new Npm() t.before(async () => { - npm.version = '1.0.0' await npm.load() npm.config.set('cache', cacheFolder) }) @@ -233,7 +237,8 @@ t.test('update notification', (t) => { t.test('npm.config not ready', (t) => { t.plan(1) - const { npm: unloaded } = mockNpm(t) + const { Npm: Unloaded } = mockNpm(t) + const unloaded = new Unloaded() t.teardown(() => { exitHandler.setNpm(npm) @@ -315,7 +320,8 @@ t.test('call exitHandler with no error', (t) => { }) t.test('defaults to log error msg if stack is missing', (t) => { - const { npm: unloaded } = mockNpm(t) + const { Npm: Unloaded } = mockNpm(t) + const unloaded = new Unloaded() t.teardown(() => { exitHandler.setNpm(npm) |