-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathindex.ts
More file actions
34 lines (29 loc) · 1.04 KB
/
index.ts
File metadata and controls
34 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
/**
* @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.dev/license
*/
import { spawnSync } from 'node:child_process';
import { join } from 'node:path';
const binPath = join(require.resolve('@angular/cli/package.json'), '../bin/ng.js');
const args = process.argv.slice(2);
const hasPackageManagerArg = args.some((a) => a.startsWith('--package-manager'));
if (!hasPackageManagerArg) {
// Ex: yarn/1.22.18 npm/? node/v16.15.1 linux x64
const packageManager = process.env['npm_config_user_agent']?.split('/')[0];
if (packageManager && ['npm', 'pnpm', 'yarn', 'bun'].includes(packageManager)) {
args.push('--package-manager', packageManager);
}
}
// Invoke ng new with any parameters provided.
const { error } = spawnSync(process.execPath, [binPath, 'new', ...args], {
stdio: 'inherit',
});
if (error) {
// eslint-disable-next-line no-console
console.error(error);
process.exitCode = 1;
}