feat(bazel): Eject Bazel (#29167)

Add command line flag to expose Bazel files on disk.

`ng build --leaveBazelFilesOnDisk`

PR Close #29167
This commit is contained in:
Keen Yee Liau 2019-03-07 11:13:10 -08:00 committed by Kara Erickson
parent 5ad2097be8
commit 36a1550e00
3 changed files with 50 additions and 28 deletions

View File

@ -20,7 +20,7 @@ class BazelBuilder implements Builder<Schema> {
run(config: BuilderConfiguration<Partial<Schema>>): Observable<BuildEvent> {
const {host, logger, workspace} = this.context;
const root: Path = workspace.root;
const {bazelCommand, targetLabel, watch} = config.options as Schema;
const {bazelCommand, leaveBazelFilesOnDisk, targetLabel, watch} = config.options as Schema;
const executable = watch ? 'ibazel' : 'bazel';
const binary = checkInstallation(executable, root) as Path;
@ -35,8 +35,10 @@ class BazelBuilder implements Builder<Schema> {
logger.error(err.message);
return {success: false};
} finally {
if (!leaveBazelFilesOnDisk) {
await deleteBazelFiles(host, bazelFiles); // this will never throw
}
}
}));
}
}

View File

@ -9,14 +9,27 @@
* Options for Bazel Builder
*/
export interface Schema {
/**
* Common commands supported by Bazel.
*/
bazelCommand: BazelCommand;
/**
* If true, leave Bazel files on disk after running command.
*/
leaveBazelFilesOnDisk?: boolean;
/**
* Target to be executed under Bazel.
*/
targetLabel: string;
/**
* If true, watch the filesystem using ibazel.
*/
watch?: boolean;
}
/**
* Common commands supported by Bazel.
*/
export enum BazelCommand {
Build = 'build',
Run = 'run',

View File

@ -10,6 +10,7 @@
},
"bazelCommand": {
"type": "string",
"description": "Common commands supported by Bazel.",
"enum": [
"run",
"build",
@ -18,6 +19,12 @@
},
"watch": {
"type": "boolean",
"description": "If true, watch the filesystem using ibazel.",
"default": false
},
"leaveBazelFilesOnDisk": {
"type": "boolean",
"description": "If true, leave Bazel files on disk after running command.",
"default": false
}
},