update
This commit is contained in:
@@ -1,15 +1,30 @@
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import { bash } from '../szci.bash.ts';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
|
||||
export let command = async () => {
|
||||
let wrappedCommand: string = '';
|
||||
let argvArray = ['deno', 'mod.ts', ...Deno.args];
|
||||
for (let i = 3; i < argvArray.length; i++) {
|
||||
wrappedCommand = wrappedCommand + argvArray[i];
|
||||
if (i + 1 !== argvArray.length) {
|
||||
wrappedCommand = wrappedCommand + ' ';
|
||||
}
|
||||
/**
|
||||
* Executes a wrapped command passed via CLI arguments.
|
||||
* Usage: szci command <your-command-here>
|
||||
*
|
||||
* This allows running arbitrary commands through szci's bash wrapper
|
||||
* which handles nvm and other environment setup.
|
||||
*/
|
||||
export const command = async (): Promise<void> => {
|
||||
// Skip 'deno', 'mod.ts', 'command' and get the rest
|
||||
const commandArgs = Deno.args.slice(1); // Skip 'command'
|
||||
|
||||
if (commandArgs.length === 0) {
|
||||
logger.log('error', 'No command specified. Usage: szci command <your-command>');
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
const wrappedCommand = commandArgs.join(' ');
|
||||
logger.log('info', `Executing command: ${wrappedCommand}`);
|
||||
|
||||
try {
|
||||
await bash(wrappedCommand);
|
||||
logger.log('ok', 'Command executed successfully');
|
||||
} catch (error) {
|
||||
logger.log('error', `Command failed: ${(error as Error).message}`);
|
||||
throw error;
|
||||
}
|
||||
await bash(wrappedCommand);
|
||||
return;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user