-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): ts-compile not reporting failures
- Loading branch information
1 parent
af66572
commit ba38135
Showing
4 changed files
with
39 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as chalk from 'chalk'; | ||
import { spawn } from 'child_process'; | ||
|
||
import {resolve as resolvePath } from 'path'; | ||
|
||
|
||
/* tslint:disable:no-console */ | ||
/** | ||
* Spawns a child process that compiles TypeScript using the specified compiler binary. | ||
* @param binary Binary name that will be used for TS compilation. | ||
* @param flags Command-line flags to be passed to binary. | ||
* @returns Promise that resolves/rejects when the child process exits. | ||
*/ | ||
export function tsCompile(binary: 'tsc' | 'ngc', flags: string[]) { | ||
|
||
// tslint:disable-next-line | ||
return new Promise((resolve, reject) => { | ||
const binaryPath = resolvePath('./node_modules/.bin/ngc'); | ||
const childProcess = spawn(binaryPath, flags, {shell: true}); | ||
|
||
// Pipe stdout and stderr from the child process. | ||
childProcess.stdout.on('data', (data: string | Buffer) => console.log(`${data}`)); | ||
childProcess.stderr.on('data', (data: string | Buffer) => console.error(chalk.default.red(`${data}`))); | ||
childProcess.on('exit', (exitCode: number) => { | ||
// tslint:disable-next-line | ||
exitCode === 0 ? resolve() : reject(`${binary} compilation failure`); | ||
}); | ||
}); | ||
} | ||
|
||
/* tslint:enable:no-console */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters