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