Skip to content

Commit 6d456bb

Browse files
authored
fix: dont write log file for completion commands (#7497)
Since npm completion is implemented by calling npm completion -- arg1 this will write a logfile for that command. I noticed this as I was trying to look through my logs for a recent command and found that it had been removed since I used enough tab completions to fill logs-max.
1 parent f078c82 commit 6d456bb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/npm.js

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class Npm {
176176
// take a long time to resolve, but that is why process.exit is called explicitly
177177
// in the exit-handler.
178178
this.unrefPromises.push(this.#logFile.load({
179+
command,
179180
path: this.logPath,
180181
logsMax: this.config.get('logs-max'),
181182
timing: this.config.get('timing'),

lib/utils/log-file.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ class LogFiles {
4848
this.#endStream()
4949
}
5050

51-
load ({ path, logsMax = Infinity, timing } = {}) {
51+
load ({ command, path, logsMax = Infinity, timing } = {}) {
52+
if (['completion'].includes(command)) {
53+
return
54+
}
55+
5256
// dir is user configurable and is required to exist so
5357
// this can error if the dir is missing or not configured correctly
5458
this.#path = path

0 commit comments

Comments
 (0)