mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 20:02:40 +08:00
Much like the framework packages, the VERSION property will eventually be set via build-time stamping but the necessary build infrastructure is not yet in place. Until then, the global require usage has been replaced with a file read and JSON parse which provides the equivalent required behavior.
31 lines
872 B
TypeScript
31 lines
872 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC 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 { readFileSync } from 'fs';
|
|
import { resolve } from 'path';
|
|
|
|
// Same structure as used in framework packages
|
|
export class Version {
|
|
public readonly major: string;
|
|
public readonly minor: string;
|
|
public readonly patch: string;
|
|
|
|
constructor(public readonly full: string) {
|
|
this.major = full.split('.')[0];
|
|
this.minor = full.split('.')[1];
|
|
this.patch = full.split('.').slice(2).join('.');
|
|
}
|
|
}
|
|
|
|
// TODO: Convert this to use build-time version stamping once implemented in the build system
|
|
export const VERSION = new Version(
|
|
(
|
|
JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8')) as { version: string }
|
|
).version,
|
|
);
|