diff options
author | Luke Karrys <luke@lukekarrys.com> | 2021-11-27 18:08:06 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2021-12-02 03:43:08 +0300 |
commit | 6734ba36dd6e07a859ab4d6eb4f264d2c0022276 (patch) | |
tree | b21a5c01d1661b4384a2251d801a590c9e14dc13 /test/lib/commands/birthday.js | |
parent | 037f2cc8c8ed9d9a092475a5a07f2a3a88915633 (diff) |
feat: streaming debug logfile
This decouples the log file writing from the terminal logging. We now
open an append only file at the start of the process and stream logs to
it. We still only display the log file message in timing mode or if
there is an error, but the file is still written regardless.
All logging now goes through `proc-log` and this is the first step to
removing `npmlog`. For now `npmlog` is still used for the terminal
logging but with a shim in front of it to make it easier to test and
use in conjunction with `proc-log`. Ref: npm/statusboard#366
This also refactors many of the tests to always use an explicit
`t.testdir` for their cache since the file is opened on each `new Npm()`.
Tests are also refactored to use more of `MockNpm` with behavior to
add config items and load `npm` if necessary. A new fixture `mockGlobals`
was also added to make much of this more ergonomic. Ref: npm/statusboard#410
Closes npm/statusboard#411
Closes npm/statusboard#367
PR-URL: https://github.com/npm/cli/pull/4062
Credit: @lukekarrys
Close: #4062
Reviewed-by: @wraithgar
Diffstat (limited to 'test/lib/commands/birthday.js')
-rw-r--r-- | test/lib/commands/birthday.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/lib/commands/birthday.js b/test/lib/commands/birthday.js index 8c95dd57b..9156d3df0 100644 --- a/test/lib/commands/birthday.js +++ b/test/lib/commands/birthday.js @@ -1,14 +1,15 @@ const t = require('tap') -const { real: mockNpm } = require('../../fixtures/mock-npm') +const { load: loadMockNpm } = require('../../fixtures/mock-npm') t.test('birthday', async t => { t.plan(2) - const { Npm } = mockNpm(t, { - libnpmexec: ({ args, yes }) => { - t.ok(yes) - t.match(args, ['@npmcli/npm-birthday']) + const { npm } = await loadMockNpm(t, { + mocks: { + libnpmexec: ({ args, yes }) => { + t.ok(yes) + t.match(args, ['@npmcli/npm-birthday']) + }, }, }) - const npm = new Npm() await npm.exec('birthday', []) }) |