Skip to content

Commit 53d07af

Browse files
committed
feat: add ability to set cli commands
1 parent 16c36da commit 53d07af

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/qwik/src/cli/utils/run-build-command.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ export async function runBuildCommand(app: AppCommand) {
2424
const isPreviewBuild = app.args.includes('preview');
2525
const buildLibScript = getScript('build.lib');
2626
const isLibraryBuild = !!buildLibScript;
27-
const buildClientScript = getScript('build.client');
28-
const buildPreviewScript = isPreviewBuild ? getScript('build.preview') : undefined;
29-
const buildServerScript = !isPreviewBuild ? getScript('build.server') : undefined;
30-
const buildStaticScript = getScript('build.static');
27+
const buildClientCommand = app.getArg("client-script") || "build.client"
28+
const buildTypesCommand = app.getArg("types-script") || "build.types"
29+
const buildPreviewCommand = app.getArg("preview-script") || "build.preview"
30+
const buildServerCommand = app.getArg("server-script") || "build.server"
31+
const buildStaticCommand = app.getArg("static-script") || "build.static"
32+
const buildClientScript = getScript(buildClientCommand);
33+
const buildPreviewScript = isPreviewBuild ? getScript(buildPreviewCommand) : undefined;
34+
const buildServerScript = !isPreviewBuild ? getScript(buildServerCommand) : undefined;
35+
const buildStaticScript = getScript(buildStaticCommand);
3136
const runSsgScript = getScript('ssg');
32-
const buildTypes = getScript('build.types');
37+
const buildTypes = getScript(buildTypesCommand);
3338
const lint = getScript('lint');
3439
const mode = app.getArg('mode');
3540

@@ -55,12 +60,12 @@ export async function runBuildCommand(app: AppCommand) {
5560

5661
if (!isLibraryBuild && !buildClientScript) {
5762
console.log(pkgJsonScripts);
58-
throw new Error(`"build.client" script not found in package.json`);
63+
throw new Error(`"${buildClientCommand}" script not found in package.json`);
5964
}
6065

6166
if (isPreviewBuild && !buildPreviewScript && !buildStaticScript) {
6267
throw new Error(
63-
`Neither "build.preview" or "build.static" script found in package.json for preview`
68+
`Neither "${buildPreviewCommand}" or "${buildStaticCommand}" script found in package.json for preview`
6469
);
6570
}
6671

0 commit comments

Comments
 (0)