bunosh 0.4.9 → 0.4.11
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/bunosh.js +4 -21
- package/package.json +1 -1
- package/src/io.js +1 -1
- package/src/program.js +21 -0
- package/src/task.js +14 -0
package/bunosh.js
CHANGED
|
@@ -326,8 +326,11 @@ process.on('exit', (code) => {
|
|
|
326
326
|
const tasksWarning = tasksExecuted.filter(ti => ti.result?.status === TaskStatus.WARNING).length;
|
|
327
327
|
|
|
328
328
|
const commandArgs = process.argv.slice(2);
|
|
329
|
+
|
|
330
|
+
// Test environment detection
|
|
329
331
|
const isTestEnvironment = process.env.NODE_ENV === 'test' ||
|
|
330
|
-
(typeof
|
|
332
|
+
(typeof jest !== 'undefined' && jest.isRunning) ||
|
|
333
|
+
(process.env.VITEST_WORKER_ID !== undefined) ||
|
|
331
334
|
commandArgs.some(arg => {
|
|
332
335
|
const lowerArg = arg.toLowerCase();
|
|
333
336
|
return lowerArg.includes('vitest') ||
|
|
@@ -338,26 +341,6 @@ process.on('exit', (code) => {
|
|
|
338
341
|
|
|
339
342
|
const ignoreFailuresMode = globalThis._bunoshIgnoreFailuresMode || false;
|
|
340
343
|
|
|
341
|
-
if (process.env.BUNOSH_DEBUG) {
|
|
342
|
-
console.log('\n[DEBUG] Exit handler:');
|
|
343
|
-
console.log(' tasksFailed:', tasksFailed);
|
|
344
|
-
console.log(' isTestEnvironment:', isTestEnvironment);
|
|
345
|
-
console.log(' ignoreFailuresMode:', ignoreFailuresMode);
|
|
346
|
-
console.log(' NODE_ENV:', process.env.NODE_ENV);
|
|
347
|
-
console.log(' commandArgs:', commandArgs);
|
|
348
|
-
console.log(' full process.argv:', process.argv);
|
|
349
|
-
if (isTestEnvironment) {
|
|
350
|
-
const matchingArg = commandArgs.find(arg => {
|
|
351
|
-
const lowerArg = arg.toLowerCase();
|
|
352
|
-
return lowerArg.includes('vitest') ||
|
|
353
|
-
lowerArg.includes('jest') ||
|
|
354
|
-
lowerArg === '--test' ||
|
|
355
|
-
lowerArg.startsWith('test:');
|
|
356
|
-
});
|
|
357
|
-
console.log(' Matched command arg:', matchingArg);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
344
|
if (tasksFailed > 0 && !isTestEnvironment && !ignoreFailuresMode) {
|
|
362
345
|
process.exitCode = 1;
|
|
363
346
|
}
|
package/package.json
CHANGED
package/src/io.js
CHANGED
package/src/program.js
CHANGED
|
@@ -606,6 +606,27 @@ ${namespaceCommands}
|
|
|
606
606
|
process.exit(1);
|
|
607
607
|
});
|
|
608
608
|
|
|
609
|
+
|
|
610
|
+
// Handle --version option before parsing
|
|
611
|
+
if (process.argv.includes('--version')) {
|
|
612
|
+
let version = '';
|
|
613
|
+
// For compiled binaries, check if version is embedded at build time
|
|
614
|
+
if (typeof BUNOSH_VERSION !== 'undefined') {
|
|
615
|
+
version = BUNOSH_VERSION;
|
|
616
|
+
} else {
|
|
617
|
+
// For development, try to read from package.json
|
|
618
|
+
try {
|
|
619
|
+
const pkgPath = new URL('../package.json', import.meta.url);
|
|
620
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
621
|
+
version = pkg.version;
|
|
622
|
+
} catch (e) {
|
|
623
|
+
version = '0.1.5'; // fallback to current version
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
console.log(version);
|
|
627
|
+
process.exit(0);
|
|
628
|
+
}
|
|
629
|
+
|
|
609
630
|
// Show help if no command provided
|
|
610
631
|
if (process.argv.length === 2) {
|
|
611
632
|
program.outputHelp();
|
package/src/task.js
CHANGED
|
@@ -138,6 +138,20 @@ export async function tryTask(name, fn, isSilent = true) {
|
|
|
138
138
|
const endTime = Date.now();
|
|
139
139
|
const duration = endTime - taskInfo.startTime;
|
|
140
140
|
|
|
141
|
+
// Check if result is a TaskResult and if it has failed
|
|
142
|
+
if (result && typeof result === 'object' && result.constructor && result.constructor.name === 'TaskResult') {
|
|
143
|
+
if (result.hasFailed || result.hasWarning) {
|
|
144
|
+
taskInfo.status = TaskStatus.WARNING;
|
|
145
|
+
taskInfo.duration = duration;
|
|
146
|
+
taskInfo.result = { status: TaskStatus.WARNING, output: result.output };
|
|
147
|
+
|
|
148
|
+
if (shouldPrint) printer.warning(name);
|
|
149
|
+
runningTasks.delete(taskInfo.id);
|
|
150
|
+
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
141
155
|
taskInfo.status = TaskStatus.SUCCESS;
|
|
142
156
|
taskInfo.duration = duration;
|
|
143
157
|
taskInfo.result = { status: TaskStatus.SUCCESS, output: result };
|