Compare commits

...

2 Commits

Author SHA1 Message Date
Ralph Khreish
36cc324dc3 chore: improve changeset 2025-04-18 23:51:14 +02:00
Kresna Sucandra
d75a6f3d00 fix: Improve error handling in task-master init for Linux containers - Fixes #211 2025-04-18 23:47:39 +02:00
2 changed files with 30 additions and 19 deletions

View File

@@ -0,0 +1,5 @@
---
'task-master-ai': patch
---
Fixed a bug that prevented the task-master from running in a Linux container

View File

@@ -46,22 +46,18 @@ export const initProject = async (options = {}) => {
}; };
// Export a function to run init as a CLI command // Export a function to run init as a CLI command
export const runInitCLI = async () => { export const runInitCLI = async (options = {}) => {
// Using spawn to ensure proper handling of stdio and process exit try {
const child = spawn('node', [resolve(__dirname, './scripts/init.js')], { const init = await import('./scripts/init.js');
stdio: 'inherit', const result = await init.initializeProject(options);
cwd: process.cwd() return result;
}); } catch (error) {
console.error('Initialization failed:', error.message);
return new Promise((resolve, reject) => { if (process.env.DEBUG === 'true') {
child.on('close', (code) => { console.error('Debug stack trace:', error.stack);
if (code === 0) { }
resolve(); throw error; // Re-throw to be handled by the command handler
} else {
reject(new Error(`Init script exited with code ${code}`));
} }
});
});
}; };
// Export version information // Export version information
@@ -79,11 +75,21 @@ if (import.meta.url === `file://${process.argv[1]}`) {
program program
.command('init') .command('init')
.description('Initialize a new project') .description('Initialize a new project')
.action(() => { .option('-y, --yes', 'Skip prompts and use default values')
runInitCLI().catch((err) => { .option('-n, --name <n>', 'Project name')
.option('-d, --description <description>', 'Project description')
.option('-v, --version <version>', 'Project version', '0.1.0')
.option('-a, --author <author>', 'Author name')
.option('--skip-install', 'Skip installing dependencies')
.option('--dry-run', 'Show what would be done without making changes')
.option('--aliases', 'Add shell aliases (tm, taskmaster)')
.action(async (cmdOptions) => {
try {
await runInitCLI(cmdOptions);
} catch (err) {
console.error('Init failed:', err.message); console.error('Init failed:', err.message);
process.exit(1); process.exit(1);
}); }
}); });
program program