Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review: use execFileSync for cross-platform safety, defer pm2 resolution

[._.]/ Adam Eivy4beec06a7c01
diff --git a/package.json b/package.json
index 59de4fa859..0f4cd98681 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.27.0",
+ "version": "1.27.1",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
@@ -25,7 +25,7 @@
"setup:db": "node scripts/setup-db.js",
"setup:browser": "node scripts/setup-browser.js",
"setup:ghostty": "node scripts/setup-ghostty.js",
- "update": "bash update.sh",
+ "update": "node -e \"const{spawnSync:s}=require('child_process');const w=process.platform==='win32';const r=s(w?'powershell':'bash',w?['-File','update.ps1']:['update.sh'],{stdio:'inherit'});process.exit(r.status??1)\"",
"test": "npm test --prefix server"
},
"devDependencies": {
diff --git a/scripts/dev-start.js b/scripts/dev-start.js
index 32dcef80c4..0e7124f838 100644
--- a/scripts/dev-start.js
+++ b/scripts/dev-start.js
@@ -12,9 +12,17 @@ import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const __dirname = dirname(fileURLToPath(import.meta.url));
-const PM2 = join(dirname(require.resolve('pm2/package.json')), 'bin', 'pm2');
const ECO = 'ecosystem.config.cjs';
+// Ensure dependencies are installed BEFORE resolving pm2 path
+// (pm2 lives in node_modules — require.resolve fails if deps are missing)
+execFileSync(process.execPath, [join(__dirname, 'ensure-deps.js')], {
+ stdio: 'inherit',
+ windowsHide: true
+});
+
+const PM2 = join(dirname(require.resolve('pm2/package.json')), 'bin', 'pm2');
+
function pm2(...args) {
execFileSync(process.execPath, [PM2, ...args], {
stdio: 'inherit',
@@ -22,12 +30,6 @@ function pm2(...args) {
});
}
-// Ensure dependencies are installed (handles missing node_modules, ENOTEMPTY retries)
-execFileSync(process.execPath, [join(__dirname, 'ensure-deps.js')], {
- stdio: 'inherit',
- windowsHide: true
-});
-
// Ensure PostgreSQL is running (gracefully skips if Docker unavailable)
execFileSync(process.execPath, [join(__dirname, 'setup-db.js')], {
stdio: 'inherit',
diff --git a/scripts/ensure-deps.js b/scripts/ensure-deps.js
index 77145587a5..32fd65975d 100644
--- a/scripts/ensure-deps.js
+++ b/scripts/ensure-deps.js
@@ -4,11 +4,12 @@
* Handles ENOTEMPTY npm bug by retrying with clean node_modules.
*/
import { existsSync, rmSync } from 'fs';
-import { execSync } from 'child_process';
+import { execFileSync } from 'child_process';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
+const NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm';
const WORKSPACES = [
{ dir: ROOT, label: 'root' },
@@ -18,13 +19,13 @@ const WORKSPACES = [
function install(dir, label) {
try {
- execSync('npm install', { cwd: dir, stdio: 'inherit' });
+ execFileSync(NPM, ['install'], { cwd: dir, stdio: 'inherit', windowsHide: true });
return true;
} catch {
console.log(`⚠️ npm install failed for ${label} — cleaning node_modules and retrying...`);
rmSync(join(dir, 'node_modules'), { recursive: true, force: true });
try {
- execSync('npm install', { cwd: dir, stdio: 'inherit' });
+ execFileSync(NPM, ['install'], { cwd: dir, stdio: 'inherit', windowsHide: true });
return true;
} catch {
console.error(`❌ npm install failed for ${label} after retry`);