|
8 | 8 |
|
9 | 9 | import 'symbol-observable'; |
10 | 10 | // symbol polyfill must go first |
11 | | -import * as fs from 'fs'; |
| 11 | +import { promises as fs } from 'fs'; |
12 | 12 | import * as path from 'path'; |
13 | 13 | import { SemVer } from 'semver'; |
14 | 14 | import { VERSION } from '../models/version'; |
15 | 15 | import { colors } from '../utilities/color'; |
16 | 16 | import { isWarningEnabled } from '../utilities/config'; |
17 | 17 |
|
18 | | -// Check if we need to profile this CLI run. |
19 | | -if (process.env['NG_CLI_PROFILING']) { |
20 | | - let profiler: { |
21 | | - startProfiling: (name?: string, recsamples?: boolean) => void; |
22 | | - stopProfiling: (name?: string) => unknown; |
23 | | - }; |
24 | | - try { |
25 | | - profiler = require('v8-profiler-node8'); // eslint-disable-line import/no-extraneous-dependencies |
26 | | - } catch (err) { |
27 | | - throw new Error( |
28 | | - `Could not require 'v8-profiler-node8'. You must install it separetely with ` + |
29 | | - `'npm install v8-profiler-node8 --no-save'.\n\nOriginal error:\n\n${err}`, |
30 | | - ); |
31 | | - } |
32 | | - |
33 | | - profiler.startProfiling(); |
34 | | - |
35 | | - const exitHandler = (options: { cleanup?: boolean; exit?: boolean }) => { |
36 | | - if (options.cleanup) { |
37 | | - const cpuProfile = profiler.stopProfiling(); |
38 | | - fs.writeFileSync( |
39 | | - path.resolve(process.cwd(), process.env.NG_CLI_PROFILING || '') + '.cpuprofile', |
40 | | - JSON.stringify(cpuProfile), |
41 | | - ); |
42 | | - } |
43 | | - |
44 | | - if (options.exit) { |
45 | | - process.exit(); |
46 | | - } |
47 | | - }; |
48 | | - |
49 | | - process.on('exit', () => exitHandler({ cleanup: true })); |
50 | | - process.on('SIGINT', () => exitHandler({ exit: true })); |
51 | | - process.on('uncaughtException', () => exitHandler({ exit: true })); |
52 | | -} |
53 | | - |
54 | 18 | (async () => { |
55 | 19 | /** |
56 | 20 | * Disable Browserslist old data warning as otherwise with every release we'd need to update this dependency |
@@ -87,7 +51,7 @@ if (process.env['NG_CLI_PROFILING']) { |
87 | 51 | let localVersion = cli.VERSION?.full; |
88 | 52 | if (!localVersion) { |
89 | 53 | try { |
90 | | - const localPackageJson = await fs.promises.readFile( |
| 54 | + const localPackageJson = await fs.readFile( |
91 | 55 | path.join(path.dirname(projectLocalCli), '../../package.json'), |
92 | 56 | 'utf-8', |
93 | 57 | ); |
|
0 commit comments