From de55da72fa51296199be929ac61cd9808f802a39 Mon Sep 17 00:00:00 2001 From: Bryan Field Date: Tue, 31 Mar 2026 16:30:31 -0400 Subject: [PATCH 1/2] fix: use windowsHide for git child processes on Windows When running under pm2 there is no visible console; without windowsHide, Windows spawns flashing cmd windows for each execSync. close #35 Made-with: Cursor --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2482a71..8a8c2b3 100644 --- a/index.js +++ b/index.js @@ -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 }; + module.exports = class LCL { constructor(dir = process.cwd()) { this.gitDirStr = ''; @@ -38,6 +44,7 @@ module.exports = class LCL { let gitTag; try { const opts = { + ...baseExecOptions, cwd: this.cwd, maxBuffer: 1024 * 1024 * 1024, // Date: Tue, 31 Mar 2026 17:48:22 -0400 Subject: [PATCH 2/2] also update line-diff to include windowsHide --- line-diff.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/line-diff.js b/line-diff.js index b67627c..8174e86 100644 --- a/line-diff.js +++ b/line-diff.js @@ -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 = /@@ -(.*) \+(.*) @@/; @@ -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');