Skip to content

Commit 64c9a05

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular/cli): convert VERSION property from require to file read
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.
1 parent c7e3923 commit 64c9a05

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/angular/cli/models/version.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import { readFileSync } from 'fs';
10+
import { resolve } from 'path';
11+
912
// Same structure as used in framework packages
1013
export class Version {
1114
public readonly major: string;
@@ -19,4 +22,9 @@ export class Version {
1922
}
2023
}
2124

22-
export const VERSION = new Version(require('../package.json').version);
25+
// TODO: Convert this to use build-time version stamping once implemented in the build system
26+
export const VERSION = new Version(
27+
(
28+
JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8')) as { version: string }
29+
).version,
30+
);

0 commit comments

Comments
 (0)