mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
41 lines
1,014 B
TypeScript
41 lines
1,014 B
TypeScript
|
import { getContext } from './actions/context.js';
|
||
|
|
||
|
import { install } from './actions/install.js';
|
||
|
import { help } from './actions/help.js';
|
||
|
import { verify } from './actions/verify.js';
|
||
|
import { setStdout } from './messages.js';
|
||
|
|
||
|
const exit = () => process.exit(0);
|
||
|
process.on('SIGINT', exit);
|
||
|
process.on('SIGTERM', exit);
|
||
|
|
||
|
export async function main() {
|
||
|
// NOTE: In the v7.x version of npm, the default behavior of `npm init` was changed
|
||
|
// to no longer require `--` to pass args and instead pass `--` directly to us. This
|
||
|
// broke our arg parser, since `--` is a special kind of flag. Filtering for `--` here
|
||
|
// fixes the issue so that create-astro now works on all npm versions.
|
||
|
const cleanArgv = process.argv.slice(2).filter((arg) => arg !== '--');
|
||
|
const ctx = await getContext(cleanArgv);
|
||
|
if (ctx.help) {
|
||
|
help();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
const steps = [
|
||
|
verify,
|
||
|
install,
|
||
|
];
|
||
|
|
||
|
for (const step of steps) {
|
||
|
await step(ctx);
|
||
|
}
|
||
|
process.exit(0);
|
||
|
}
|
||
|
|
||
|
export {
|
||
|
install,
|
||
|
getContext,
|
||
|
setStdout,
|
||
|
verify,
|
||
|
};
|