algomath-extract 1.0.7 → 1.0.9
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/bin/install.js +16 -22
- package/package.json +1 -1
package/bin/install.js
CHANGED
|
@@ -328,7 +328,7 @@ throw new Error(`Unknown runtime: ${runtime}`);
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
// Check if we need elevated permissions
|
|
331
|
-
|
|
331
|
+
let needsElevated = !fs.existsSync(targetDir) || !isWritable(targetDir);
|
|
332
332
|
const isWindows = platform === 'win32';
|
|
333
333
|
const isMac = platform === 'darwin';
|
|
334
334
|
|
|
@@ -345,16 +345,17 @@ execSync(`sudo mkdir -p "${commandDir}"`, { stdio: 'inherit' });
|
|
|
345
345
|
const parentDir = path.dirname(targetDir);
|
|
346
346
|
execSync(`sudo chown -R $(whoami) "${parentDir}"`, { stdio: 'inherit' });
|
|
347
347
|
} else if (needsElevated && location === 'local') {
|
|
348
|
-
// Local install but permissions needed - try sudo
|
|
349
|
-
console.log(` Installing locally requires elevated permissions...`);
|
|
350
|
-
console.log(` This happens when .opencode was previously created with sudo.`);
|
|
351
|
-
console.log(` Running with sudo...\n`);
|
|
352
|
-
|
|
353
|
-
execSync(`sudo mkdir -p "${commandDir}"`, { stdio: 'inherit' });
|
|
354
|
-
// Fix ownership so user can write to it
|
|
355
|
-
execSync(`sudo chown -R $(whoami) "${targetDir}"`, { stdio: 'inherit' });
|
|
356
|
-
|
|
357
|
-
|
|
348
|
+
// Local install but permissions needed - try sudo
|
|
349
|
+
console.log(` Installing locally requires elevated permissions...`);
|
|
350
|
+
console.log(` This happens when .opencode was previously created with sudo.`);
|
|
351
|
+
console.log(` Running with sudo...\n`);
|
|
352
|
+
|
|
353
|
+
execSync(`sudo mkdir -p "${commandDir}"`, { stdio: 'inherit' });
|
|
354
|
+
// Fix ownership so user can write to it
|
|
355
|
+
execSync(`sudo chown -R $(whoami) "${targetDir}"`, { stdio: 'inherit' });
|
|
356
|
+
|
|
357
|
+
// Recalculate needsElevated after fixing permissions
|
|
358
|
+
needsElevated = !isWritable(commandDir);
|
|
358
359
|
}
|
|
359
360
|
|
|
360
361
|
// Copy command files
|
|
@@ -364,19 +365,12 @@ const files = fs.readdirSync(sourceDir).filter(f => f.endsWith('.md'));
|
|
|
364
365
|
for (const file of files) {
|
|
365
366
|
const source = path.join(sourceDir, file);
|
|
366
367
|
const dest = path.join(commandDir, file);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
} catch (e) {
|
|
372
|
-
// If regular copy fails, use sudo
|
|
368
|
+
|
|
369
|
+
// For any install that needs elevated permissions, use sudo
|
|
370
|
+
if (needsElevated && !isWindows) {
|
|
371
|
+
// Use sudo to copy, then fix ownership
|
|
373
372
|
execSync(`sudo cp "${source}" "${dest}"`, { stdio: 'pipe' });
|
|
374
|
-
// Fix ownership after sudo copy
|
|
375
373
|
execSync(`sudo chown $(whoami) "${dest}"`, { stdio: 'pipe' });
|
|
376
|
-
}
|
|
377
|
-
} else if (needsElevated && !isWindows) {
|
|
378
|
-
// Global install with sudo
|
|
379
|
-
execSync(`sudo cp "${source}" "${dest}"`, { stdio: 'pipe' });
|
|
380
374
|
} else {
|
|
381
375
|
fs.copyFileSync(source, dest);
|
|
382
376
|
}
|