Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const path = require('path');
const dotgitconfig = require('dotgitconfig');
const { execSync } = require('child_process');

/**
* Prevents obnoxious cmd window popping up on Windows when process runs via pm2
* instead of via an already visible terminal.
*/
const baseExecOptions = { windowsHide: true };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The PR description states that windowsHide: true should be set on all execSync options. However, line-diff.js (which is required at the end of this file) also uses execSync but has not been updated in this PR. To ensure the fix is comprehensive, please apply this change to line-diff.js as well.

Copy link
Copy Markdown
Author

@700software 700software Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


module.exports = class LCL {
constructor(dir = process.cwd()) {
this.gitDirStr = '';
Expand Down Expand Up @@ -38,6 +44,7 @@ module.exports = class LCL {
let gitTag;
try {
const opts = {
...baseExecOptions,
cwd: this.cwd,
maxBuffer: 1024 * 1024 * 1024,
// <https://stackoverflow.com/a/45578119
Expand Down Expand Up @@ -112,7 +119,7 @@ module.exports = class LCL {
}

getUserNameSync() {
return execSync(`git ${this.gitDirStr} config user.name`)
return execSync(`git ${this.gitDirStr} config user.name`, baseExecOptions)
.toString()
.trim();
}
Expand Down
8 changes: 7 additions & 1 deletion line-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

const { execSync } = require('child_process');

/**
* Avoid cmd popups on Windows when there is no visible console (e.g. pm2).
* @see index.js baseExecOptions
*/
const execOptions = { windowsHide: true };

const fileNameReg = /diff --git a(.*) b.*/;
const lineReg = /@@ -(.*) \+(.*) @@/;

Expand All @@ -25,7 +31,7 @@ module.exports = (options = {}) => {
currentBranch,
filter,
].join(' ');
const str = execSync(cmd).toString().trim();
const str = execSync(cmd, execOptions).toString().trim();
if (!str) return null;
const diffMap = {};
const diffArray = str.split('\n');
Expand Down