nightytidy 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/agent/cli-bridge.js
CHANGED
|
@@ -78,11 +78,17 @@ export class CliBridge {
|
|
|
78
78
|
_run(args, onOutput, opts = {}) {
|
|
79
79
|
return new Promise((resolve) => {
|
|
80
80
|
const binPath = path.resolve(import.meta.dirname, '../../bin/nightytidy.js');
|
|
81
|
-
const
|
|
81
|
+
const spawnOpts = {
|
|
82
82
|
cwd: this.projectDir,
|
|
83
83
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
84
84
|
windowsHide: true,
|
|
85
|
-
}
|
|
85
|
+
};
|
|
86
|
+
// On Windows, use shell mode to prevent a visible console window.
|
|
87
|
+
// cmd.exe inherits the parent's hidden console instead of creating a new one.
|
|
88
|
+
if (process.platform === 'win32') {
|
|
89
|
+
spawnOpts.shell = true;
|
|
90
|
+
}
|
|
91
|
+
const proc = spawn('node', [binPath, ...args], spawnOpts);
|
|
86
92
|
this.activeProcess = proc;
|
|
87
93
|
|
|
88
94
|
let stdout = '';
|
package/src/agent/keep-awake.js
CHANGED
|
@@ -25,7 +25,7 @@ export function acquireKeepAwake() {
|
|
|
25
25
|
keepAwakeProcess = spawn('powershell', [
|
|
26
26
|
'-NoProfile', '-WindowStyle', 'Hidden', '-Command',
|
|
27
27
|
`Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class SleepPreventer { [DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags); }'; [SleepPreventer]::SetThreadExecutionState(0x80000001); while($true) { Start-Sleep -Seconds 3600 }`,
|
|
28
|
-
], { stdio: 'ignore', detached: false });
|
|
28
|
+
], { stdio: 'ignore', detached: false, windowsHide: true });
|
|
29
29
|
keepAwakeProcess.unref();
|
|
30
30
|
keepAwakeProcess.on('error', () => { keepAwakeProcess = null; });
|
|
31
31
|
debug('Sleep prevention acquired (Windows SetThreadExecutionState)');
|
package/src/agent/setup-flow.js
CHANGED
|
@@ -12,6 +12,7 @@ import { createServer } from 'node:http';
|
|
|
12
12
|
import { spawn } from 'node:child_process';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
14
|
import path from 'node:path';
|
|
15
|
+
import os from 'node:os';
|
|
15
16
|
import chalk from 'chalk';
|
|
16
17
|
import { getConfigDir, ensureConfigDir } from './config.js';
|
|
17
18
|
import { registerService } from './service.js';
|
|
@@ -176,7 +177,21 @@ export async function setupAgent() {
|
|
|
176
177
|
|
|
177
178
|
console.log(chalk.bold('\nStep 4: Start agent'));
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
if (process.platform === 'win32' && serviceResult.success) {
|
|
181
|
+
// On Windows, launch via the VBS script we just registered — this is the
|
|
182
|
+
// only way to start a Node.js process with NO visible console window.
|
|
183
|
+
const vbsPath = path.join(
|
|
184
|
+
os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Windows',
|
|
185
|
+
'Start Menu', 'Programs', 'Startup', 'NightyTidy Agent.vbs',
|
|
186
|
+
);
|
|
187
|
+
spawn('wscript', [vbsPath], { detached: true, stdio: 'ignore' }).unref();
|
|
188
|
+
} else {
|
|
189
|
+
// Unix or fallback: spawn directly (no console window issue on Unix)
|
|
190
|
+
spawn(process.execPath, [BIN_PATH, 'agent'], {
|
|
191
|
+
detached: true,
|
|
192
|
+
stdio: 'ignore',
|
|
193
|
+
}).unref();
|
|
194
|
+
}
|
|
180
195
|
console.log(chalk.green(' Agent started'));
|
|
181
196
|
|
|
182
197
|
// ── Done ──────────────────────────────────────────────────────────────────
|