Skip to content

Commit 0aaafe5

Browse files
committed
fixup! feat: write eresolve error files to the logs directory
1 parent 7bbd88f commit 0aaafe5

File tree

7 files changed

+9
-11
lines changed

7 files changed

+9
-11
lines changed

lib/npm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ class Npm extends EventEmitter {
370370
return this.config.get('logs-dir') || join(this.cache, '_logs')
371371
}
372372

373-
logPath = (file = '') => {
374-
return resolve(this.logsDir, `${this.#runId}-${file}`)
373+
get logPath () {
374+
return resolve(this.logsDir, `${this.#runId}-`)
375375
}
376376

377377
get timingFile () {

lib/utils/exit-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const exitHandler = err => {
183183
const { summary, detail, files = [] } = errorMessage(err, npm)
184184

185185
for (let [file, content] of files) {
186-
file = npm.logPath(file)
186+
file = `${npm.logPath}${file}`
187187
content = `'Log files:\n${npm.logFiles.join('\n')}\n\n${content.trim()}\n`
188188
try {
189189
fs.withOwnerSync(

lib/utils/log-file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class LogFiles {
7777
return
7878
}
7979

80-
log.verbose('logfile', `logs-max:${logsMax} dir:${this.#path()}`)
80+
log.verbose('logfile', `logs-max:${logsMax} dir:${this.#path}`)
8181

8282
// Pipe our initial stream to our new file stream and
8383
// set that as the new log logstream for future writes
@@ -157,7 +157,7 @@ class LogFiles {
157157
}
158158

159159
#getLogFilePath (count = '') {
160-
return this.#path(`debug-${count}.log`)
160+
return `${this.#path}debug-${count}.log`
161161
}
162162

163163
#openLogFile () {

lib/utils/timers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Timers extends EE {
6969

7070
load ({ path } = {}) {
7171
if (path) {
72-
this.file = path('timing.json')
72+
this.file = `${path}timing.json`
7373
}
7474
}
7575

test/lib/utils/exit-handler.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,7 @@ t.test('files from error message with error', async (t) => {
345345
'@npmcli/fs': {
346346
...fs,
347347
writeFileSync: (dir) => {
348-
console.log(dir)
349348
if (dir.includes('LOGS_DIR') && dir.endsWith('error-file.txt')) {
350-
console.log('throw')
351349
throw new Error('err')
352350
}
353351
},

test/lib/utils/log-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const loadLogFile = async (t, { buffer = [], mocks, testdir = {}, ...options } =
4949
buffer.forEach((b) => logFile.log(...b))
5050

5151
const id = getId()
52-
await logFile.load({ path: (f = '') => path.join(root, `${id}-${f}`), ...options })
52+
await logFile.load({ path: path.join(root, `${id}-`), ...options })
5353

5454
t.teardown(() => logFile.off())
5555
return {

test/lib/utils/timers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ t.test('writes file', async (t) => {
7272
const dir = t.testdir()
7373
process.emit('time', 'foo')
7474
process.emit('timeEnd', 'foo')
75-
timers.load({ path: (f) => resolve(dir, `TIMING_FILE-${f}`) })
75+
timers.load({ path: resolve(dir, `TIMING_FILE-`) })
7676
timers.writeFile({ some: 'data' })
7777
const data = JSON.parse(fs.readFileSync(resolve(dir, 'TIMING_FILE-timing.json')))
7878
t.match(data, {
@@ -88,7 +88,7 @@ t.test('fails to write file', async (t) => {
8888
const { logs, timers } = mockTimers(t)
8989
const dir = t.testdir()
9090

91-
timers.load({ path: () => join(dir, 'does', 'not', 'exist') })
91+
timers.load({ path: join(dir, 'does', 'not', 'exist') })
9292
timers.writeFile()
9393

9494
t.match(logs.warn, [['timing', 'could not write timing file']])

0 commit comments

Comments
 (0)