2025-10-26 15:23:56 +00:00
|
|
|
import { bash } from '../szci.bash.ts';
|
2025-12-14 01:42:14 +00:00
|
|
|
import { logger } from '../szci.logging.ts';
|
2016-06-11 20:22:00 +02:00
|
|
|
|
2025-12-14 01:42:14 +00:00
|
|
|
/**
|
|
|
|
|
* 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;
|
2017-03-08 14:50:41 +01:00
|
|
|
}
|
2018-04-04 22:25:13 +02:00
|
|
|
};
|