unitup 0.1.2 → 0.1.3
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/cli.js +8 -2
- package/src/utils.js +21 -4
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -108,12 +108,15 @@ export function parseArgs(argv) {
|
|
|
108
108
|
} else if (arg.startsWith('--runtime=')) {
|
|
109
109
|
result.flags.runtime = arg.slice(10);
|
|
110
110
|
i++;
|
|
111
|
-
} else if (arg === '--runtime-arg') {
|
|
111
|
+
} else if (arg === '--runtime-arg' || arg === '--runtime-args') {
|
|
112
112
|
if (argv[i + 1]) result.flags.runtimeArgs.push(argv[i + 1]);
|
|
113
113
|
i += 2;
|
|
114
114
|
} else if (arg.startsWith('--runtime-arg=')) {
|
|
115
115
|
result.flags.runtimeArgs.push(arg.slice(14));
|
|
116
116
|
i++;
|
|
117
|
+
} else if (arg.startsWith('--runtime-args=')) {
|
|
118
|
+
result.flags.runtimeArgs.push(arg.slice(15));
|
|
119
|
+
i++;
|
|
117
120
|
} else if (arg === '--command') {
|
|
118
121
|
result.flags.command = argv[i + 1] || '';
|
|
119
122
|
i += 2;
|
|
@@ -162,12 +165,15 @@ export function parseArgs(argv) {
|
|
|
162
165
|
} else if (arg.startsWith('--restart=')) {
|
|
163
166
|
result.flags.restart = arg.slice(10);
|
|
164
167
|
i++;
|
|
165
|
-
} else if (arg === '--arg') {
|
|
168
|
+
} else if (arg === '--arg' || arg === '--args') {
|
|
166
169
|
if (argv[i + 1]) result.flags.args.push(argv[i + 1]);
|
|
167
170
|
i += 2;
|
|
168
171
|
} else if (arg.startsWith('--arg=')) {
|
|
169
172
|
result.flags.args.push(arg.slice(6));
|
|
170
173
|
i++;
|
|
174
|
+
} else if (arg.startsWith('--args=')) {
|
|
175
|
+
result.flags.args.push(arg.slice(7));
|
|
176
|
+
i++;
|
|
171
177
|
} else if (arg === '--lines' || arg === '-n') {
|
|
172
178
|
result.flags.lines = parseInt(argv[i + 1] || '100', 10);
|
|
173
179
|
i += 2;
|
package/src/utils.js
CHANGED
|
@@ -180,10 +180,17 @@ export function readAppMetadata(name) {
|
|
|
180
180
|
const data = JSON.parse(content);
|
|
181
181
|
if (!data) return null;
|
|
182
182
|
|
|
183
|
-
// Normalization for legacy metadata format
|
|
184
183
|
const command = data.command || data.node || process.execPath;
|
|
185
184
|
const args = data.args || (data.script ? [data.script] : []);
|
|
186
|
-
|
|
185
|
+
let runtime = data.runtime;
|
|
186
|
+
if (!runtime || (runtime === 'node' && data.command)) {
|
|
187
|
+
const baseCmd = path.basename(command).toLowerCase();
|
|
188
|
+
if (baseCmd !== 'node' && baseCmd !== 'nodejs') {
|
|
189
|
+
runtime = 'custom';
|
|
190
|
+
} else {
|
|
191
|
+
runtime = 'node';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
187
194
|
const script = data.script || args[0] || command;
|
|
188
195
|
const cwd = data.cwd || (script ? path.dirname(script) : process.cwd());
|
|
189
196
|
|
|
@@ -472,7 +479,7 @@ export function saveScheduleMetadata(meta) {
|
|
|
472
479
|
name: safeName,
|
|
473
480
|
group: meta.group || 'default',
|
|
474
481
|
type: 'timer',
|
|
475
|
-
runtime: meta.runtime || 'node',
|
|
482
|
+
runtime: meta.runtime || (meta.command ? 'custom' : 'node'),
|
|
476
483
|
command,
|
|
477
484
|
args,
|
|
478
485
|
cwd: meta.cwd ? resolveAbsolutePath(meta.cwd) : process.cwd(),
|
|
@@ -502,7 +509,17 @@ export function readScheduleMetadata(name) {
|
|
|
502
509
|
const filePath = getScheduleMetadataPath(name);
|
|
503
510
|
if (!fs.existsSync(filePath)) return null;
|
|
504
511
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
505
|
-
|
|
512
|
+
const meta = JSON.parse(content);
|
|
513
|
+
if (!meta) return null;
|
|
514
|
+
|
|
515
|
+
// Normalization for legacy metadata format where runtime defaulted to 'node' for custom commands
|
|
516
|
+
if (meta.runtime === 'node' && meta.command) {
|
|
517
|
+
const baseCmd = path.basename(meta.command).toLowerCase();
|
|
518
|
+
if (baseCmd !== 'node' && baseCmd !== 'nodejs') {
|
|
519
|
+
meta.runtime = 'custom';
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return meta;
|
|
506
523
|
} catch {
|
|
507
524
|
return null;
|
|
508
525
|
}
|