Skip to content

Commit

Permalink
Add --skipBuild flag (#3)
Browse files Browse the repository at this point in the history
- and hoist --compilerVersion `.check()` to be near --compilerVersion
`.option()`

Will be useful for roblox-ts compiler workflow which runs
`create-roblox-ts`. It will:
1. Run with `--skipBuild`
2. Install local repo as roblox-ts dependency in template project
3. `npm run build`
  • Loading branch information
osyrisrblx authored Oct 15, 2023
1 parent f179630 commit 6b2af34
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface InitOptions {
prettier?: boolean;
vscode?: boolean;
packageManager?: PackageManager;
skipBuild?: boolean;
}

enum InitMode {
Expand Down Expand Up @@ -371,7 +372,9 @@ async function init(argv: yargs.Arguments<InitOptions>, initMode: InitMode) {
await fs.copy(templateDir, cwd);
});

await benchmark("Compiling..", () => cmd("npm run build", cwd));
if (!argv.skipBuild) {
await benchmark("Compiling..", () => cmd(selectedPackageManager.build, cwd));
}
}

const GAME_DESCRIPTION = "Generate a Roblox place";
Expand All @@ -391,6 +394,14 @@ export = {
string: true,
describe: "roblox-ts compiler version",
})
.check(argv => {
if (argv.compilerVersion !== undefined && !/^\d+\.\d+\.\d+$/.test(argv.compilerVersion)) {
throw new InitError(
"Invalid --compilerVersion. You must specify a version in the form of X.X.X. (i.e. --compilerVersion 1.2.3)",
);
}
return true;
}, true)
.option("dir", {
string: true,
describe: "Project directory",
Expand Down Expand Up @@ -420,14 +431,10 @@ export = {
choices: Object.values(PackageManager),
describe: "Choose an alternative package manager",
})
.check(argv => {
if (argv.compilerVersion !== undefined && !/^\d+\.\d+\.\d+$/.test(argv.compilerVersion)) {
throw new InitError(
"Invalid --compilerVersion. You must specify a version in the form of X.X.X. (i.e. --compilerVersion 1.2.3)",
);
}
return true;
}, true)
.option("skipBuild", {
boolean: true,
describe: "Do not run build script",
})

.command([InitMode.Game, InitMode.Place], GAME_DESCRIPTION, {}, argv => init(argv as never, InitMode.Game))
.command(InitMode.Model, MODEL_DESCRIPTION, {}, argv => init(argv as never, InitMode.Model))
Expand Down

0 comments on commit 6b2af34

Please sign in to comment.