Skip to content

Commit

Permalink
fix(bazel): Builder should invoke local bazel/iblaze (#28303)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Keen Yee Liau authored and jasonaden committed Jan 28, 2019
1 parent 260ac20 commit 12b8a6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/bazel/src/builders/bazel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/// <reference types='node'/>
import {spawn, spawnSync} from 'child_process';
import {join} from 'path';
import {Observable, Subject} from 'rxjs';

export type Executable = 'bazel' | 'ibazel';
Expand All @@ -17,7 +18,8 @@ export function runBazel(
projectDir: string, executable: Executable, command: Command, workspaceTarget: string,
flags: string[]): Observable<void> {
const doneSubject = new Subject<void>();
const buildProcess = spawn(executable, [command, workspaceTarget, ...flags], {
const bin = join(projectDir, 'node_modules', '.bin', executable);
const buildProcess = spawn(bin, [command, workspaceTarget, ...flags], {
cwd: projectDir,
stdio: 'inherit',
shell: false,
Expand All @@ -35,7 +37,8 @@ export function runBazel(
}

export function checkInstallation(executable: Executable, projectDir: string) {
const child = spawnSync(executable, ['version'], {
const bin = join(projectDir, 'node_modules', '.bin', executable);
const child = spawnSync(bin, ['version'], {
cwd: projectDir,
shell: false,
});
Expand Down
5 changes: 3 additions & 2 deletions packages/bazel/src/builders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import {BuildEvent, Builder, BuilderConfiguration, BuilderContext} from '@angular-devkit/architect';
import {getSystemPath, resolve} from '@angular-devkit/core';
import {Observable, of } from 'rxjs';
import {catchError, map, tap} from 'rxjs/operators';
import {catchError, map} from 'rxjs/operators';

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

// TODO: Support passing flags.
Expand Down

0 comments on commit 12b8a6e

Please sign in to comment.