bs9 1.3.8 → 1.3.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/package.json +1 -1
- package/src/commands/resurrect.ts +7 -0
- package/src/commands/save.ts +17 -4
package/package.json
CHANGED
|
@@ -59,6 +59,13 @@ export async function resurrectCommand(name: string, options: ResurrectOptions):
|
|
|
59
59
|
// Load backup configuration
|
|
60
60
|
const backupConfig = JSON.parse(require('node:fs').readFileSync(backupFile, 'utf8'));
|
|
61
61
|
|
|
62
|
+
// Check if the file exists
|
|
63
|
+
const filePath = backupConfig.file;
|
|
64
|
+
if (!require('node:fs').existsSync(filePath)) {
|
|
65
|
+
console.error(`❌ Service file not found: ${filePath}`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
62
69
|
// Restore service using backup configuration
|
|
63
70
|
const { startCommand } = await import("./start.js");
|
|
64
71
|
await startCommand(backupConfig.file, {
|
package/src/commands/save.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { execSync } from "node:child_process";
|
|
13
|
-
import { join } from "node:path";
|
|
13
|
+
import { join, resolve } from "node:path";
|
|
14
14
|
import { getPlatformInfo } from "../platform/detect.js";
|
|
15
15
|
|
|
16
16
|
interface SaveOptions {
|
|
@@ -239,10 +239,23 @@ function extractFileFromConfig(serviceConfig: string): string {
|
|
|
239
239
|
const execMatch = serviceConfig.match(/ExecStart=([^\n]+)/);
|
|
240
240
|
if (execMatch) {
|
|
241
241
|
const execLine = execMatch[1].trim();
|
|
242
|
-
//
|
|
243
|
-
|
|
242
|
+
// Handle both "bun run" and direct "bun" execution
|
|
243
|
+
let fileMatch;
|
|
244
|
+
if (execLine.includes('bun run')) {
|
|
245
|
+
// Extract the file path from "bun run <file>"
|
|
246
|
+
fileMatch = execLine.match(/bun run\s+(?:'([^']+)'|"([^"]+)"|([^\s]+))/);
|
|
247
|
+
} else {
|
|
248
|
+
// Extract the file path from "bun <file>"
|
|
249
|
+
fileMatch = execLine.match(/bun\s+(?:'([^']+)'|"([^"]+)"|([^\s]+))/);
|
|
250
|
+
}
|
|
251
|
+
|
|
244
252
|
if (fileMatch) {
|
|
245
|
-
|
|
253
|
+
const filePath = fileMatch[1] || fileMatch[2] || fileMatch[3];
|
|
254
|
+
// If it's a relative path, resolve it relative to the working directory
|
|
255
|
+
if (!filePath.startsWith('/') && !filePath.startsWith('~')) {
|
|
256
|
+
return resolve(filePath);
|
|
257
|
+
}
|
|
258
|
+
return filePath;
|
|
246
259
|
}
|
|
247
260
|
}
|
|
248
261
|
return '';
|