Skip to content

Commit 12b8a6e

Browse files
Keen Yee Liaujasonaden
Keen Yee Liau
authored andcommittedJan 28, 2019
fix(bazel): Builder should invoke local bazel/iblaze (#28303)
Builder for `@angular/bazel` schematics should not expect bazel/ibazel to be on the PATH. It should instead invoke the local executable installed by yarn/npm. PR Close #28303
1 parent 260ac20 commit 12b8a6e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎packages/bazel/src/builders/bazel.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/// <reference types='node'/>
1010
import {spawn, spawnSync} from 'child_process';
11+
import {join} from 'path';
1112
import {Observable, Subject} from 'rxjs';
1213

1314
export type Executable = 'bazel' | 'ibazel';
@@ -17,7 +18,8 @@ export function runBazel(
1718
projectDir: string, executable: Executable, command: Command, workspaceTarget: string,
1819
flags: string[]): Observable<void> {
1920
const doneSubject = new Subject<void>();
20-
const buildProcess = spawn(executable, [command, workspaceTarget, ...flags], {
21+
const bin = join(projectDir, 'node_modules', '.bin', executable);
22+
const buildProcess = spawn(bin, [command, workspaceTarget, ...flags], {
2123
cwd: projectDir,
2224
stdio: 'inherit',
2325
shell: false,
@@ -35,7 +37,8 @@ export function runBazel(
3537
}
3638

3739
export function checkInstallation(executable: Executable, projectDir: string) {
38-
const child = spawnSync(executable, ['version'], {
40+
const bin = join(projectDir, 'node_modules', '.bin', executable);
41+
const child = spawnSync(bin, ['version'], {
3942
cwd: projectDir,
4043
shell: false,
4144
});

‎packages/bazel/src/builders/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import {BuildEvent, Builder, BuilderConfiguration, BuilderContext} from '@angular-devkit/architect';
1212
import {getSystemPath, resolve} from '@angular-devkit/core';
1313
import {Observable, of } from 'rxjs';
14-
import {catchError, map, tap} from 'rxjs/operators';
14+
import {catchError, map} from 'rxjs/operators';
1515

1616
import {checkInstallation, runBazel} from './bazel';
1717
import {Schema} from './schema';
@@ -28,7 +28,8 @@ class BazelBuilder implements Builder<Schema> {
2828
if (!checkInstallation(executable, projectRoot)) {
2929
throw new Error(
3030
`Could not run ${executable}. Please make sure that the ` +
31-
`"${executable}" command is available in the $PATH.`);
31+
`"${executable}" command is installed by running ` +
32+
`"npm install" or "yarn install".`);
3233
}
3334

3435
// TODO: Support passing flags.

0 commit comments

Comments
 (0)
Please sign in to comment.