Skip to content

Commit

Permalink
fix: dont write log file for completion commands (#7497)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lukekarrys committed May 9, 2024
1 parent f078c82 commit 6d456bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class Npm {
// take a long time to resolve, but that is why process.exit is called explicitly
// in the exit-handler.
this.unrefPromises.push(this.#logFile.load({
command,
path: this.logPath,
logsMax: this.config.get('logs-max'),
timing: this.config.get('timing'),
Expand Down
6 changes: 5 additions & 1 deletion lib/utils/log-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class LogFiles {
this.#endStream()
}

load ({ path, logsMax = Infinity, timing } = {}) {
load ({ command, path, logsMax = Infinity, timing } = {}) {
if (['completion'].includes(command)) {
return
}

// dir is user configurable and is required to exist so
// this can error if the dir is missing or not configured correctly
this.#path = path
Expand Down

0 comments on commit 6d456bb

Please sign in to comment.