Skip to content

Commit a2cecf0

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular/cli): remove outdated performance profiling code
1 parent c1623c4 commit a2cecf0

File tree

1 file changed

+2
-38
lines changed

1 file changed

+2
-38
lines changed

packages/angular/cli/lib/init.ts

+2-38
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,13 @@
88

99
import 'symbol-observable';
1010
// symbol polyfill must go first
11-
import * as fs from 'fs';
11+
import { promises as fs } from 'fs';
1212
import * as path from 'path';
1313
import { SemVer } from 'semver';
1414
import { VERSION } from '../models/version';
1515
import { colors } from '../utilities/color';
1616
import { isWarningEnabled } from '../utilities/config';
1717

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-
5418
(async () => {
5519
/**
5620
* 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']) {
8751
let localVersion = cli.VERSION?.full;
8852
if (!localVersion) {
8953
try {
90-
const localPackageJson = await fs.promises.readFile(
54+
const localPackageJson = await fs.readFile(
9155
path.join(path.dirname(projectLocalCli), '../../package.json'),
9256
'utf-8',
9357
);

0 commit comments

Comments
 (0)