Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/cli): initial minimal BEP support
- Loading branch information
Showing
4 changed files
with
143 additions
and
9 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 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 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 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,68 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import * as fs from 'fs'; | ||
|
||
|
||
export interface BuildEventMessage { | ||
id: {}; | ||
[key: string]: {}; | ||
} | ||
|
||
export class BepGenerator { | ||
private constructor() {} | ||
|
||
static createBuildStarted(command: string, time?: number): BuildEventMessage { | ||
return { | ||
id: { started: {} }, | ||
started: { | ||
command, | ||
start_time_millis: time == undefined ? Date.now() : time, | ||
}, | ||
}; | ||
} | ||
|
||
static createBuildFinished(code: number, time?: number): BuildEventMessage { | ||
return { | ||
id: { finished: {} }, | ||
finished: { | ||
finish_time_millis: time == undefined ? Date.now() : time, | ||
exit_code: { code }, | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
export class BepJsonWriter { | ||
private stream = fs.createWriteStream(this.filename); | ||
|
||
constructor(public readonly filename: string) { | ||
|
||
} | ||
|
||
close(): void { | ||
this.stream.close(); | ||
} | ||
|
||
writeEvent(event: BuildEventMessage): void { | ||
const raw = JSON.stringify(event); | ||
|
||
this.stream.write(raw + '\n'); | ||
} | ||
|
||
writeBuildStarted(command: string, time?: number): void { | ||
const event = BepGenerator.createBuildStarted(command, time); | ||
|
||
this.writeEvent(event); | ||
} | ||
|
||
writeBuildFinished(code: number, time?: number): void { | ||
const event = BepGenerator.createBuildFinished(code, time); | ||
|
||
this.writeEvent(event); | ||
} | ||
} |