fix: failure handling
This commit is contained in:
parent
e6c2d49008
commit
855999b3a1
|
@ -33,13 +33,16 @@ const {
|
|||
try {
|
||||
await stat(destination);
|
||||
const error = new Error(
|
||||
`@flecks/create-app: destination '${destination} already exists: aborting`,
|
||||
`@flecks/create-app: destination '${destination}' already exists: aborting`,
|
||||
);
|
||||
error.code = 129;
|
||||
error.code = 1;
|
||||
throw error;
|
||||
}
|
||||
// eslint-disable-next-line no-empty
|
||||
catch (error) {}
|
||||
catch (error) {
|
||||
if ('ENOENT' !== error.code) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const fileTree = await move(name, join(__dirname, '..', 'template'));
|
||||
fileTree.pipe(
|
||||
'build/flecks.yml',
|
||||
|
@ -50,12 +53,17 @@ const {
|
|||
);
|
||||
// Write the tree.
|
||||
await fileTree.writeTo(destination);
|
||||
await install({cwd: destination, packageManager});
|
||||
await build({cwd: destination, packageManager});
|
||||
if (0 !== await install({cwd: destination, packageManager})) {
|
||||
throw new Error('installation failed');
|
||||
}
|
||||
if (0 !== await build({cwd: destination, packageManager})) {
|
||||
throw new Error('build failed');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
console.error('creation failed:', error);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
});
|
||||
await program.parseAsync(process.argv);
|
||||
|
|
|
@ -92,6 +92,7 @@ const {
|
|||
catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('creation failed:', error);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
});
|
||||
await program.parseAsync(process.argv);
|
||||
|
|
Loading…
Reference in New Issue
Block a user