Skip to content

Commit

Permalink
feat: add nest build --all flag
Browse files Browse the repository at this point in the history
  • Loading branch information
iliazeus committed Sep 28, 2023
1 parent e8a871a commit d441d5c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 15 additions & 3 deletions actions/build.action.ts
Expand Up @@ -79,9 +79,21 @@ export class BuildAction extends AbstractAction {
)!.value as string;
const configuration = await this.loader.load(configFileName);

const appNames = commandInputs
.filter((input) => input.name === 'app')
.map((input) => input.value) as string[];
const buildAll = commandOptions.find((opt) => opt.name === 'all')!
.value as boolean;

let appNames: string[];
if (buildAll) {
appNames = [undefined!]; // always include the default project

if (configuration.projects) {
appNames.push(...Object.keys(configuration.projects));
}
} else {
appNames = commandInputs
.filter((input) => input.name === 'app')
.map((input) => input.value) as string[];
}

for (const appName of appNames) {
const pathToTsconfig = getTscConfigPath(
Expand Down
3 changes: 3 additions & 0 deletions commands/build.command.ts
Expand Up @@ -23,6 +23,7 @@ export class BuildCommand extends AbstractCommand {
'--preserveWatchOutput',
'Use "preserveWatchOutput" option when using tsc watch mode.',
)
.option('--all', 'Build all projects in a monorepo')
.description('Build Nest application.')
.action(async (apps: string[], command: Command) => {
const options: Input[] = [];
Expand Down Expand Up @@ -79,6 +80,8 @@ export class BuildCommand extends AbstractCommand {
!isWebpackEnabled,
});

options.push({ name: 'all', value: !!command.all });

const inputs: Input[] = apps.map((app) => ({
name: 'app',
value: app,
Expand Down

0 comments on commit d441d5c

Please sign in to comment.