|
8 | 8 |
|
9 | 9 | import { logging } from '@angular-devkit/core';
|
10 | 10 | import { spawnSync } from 'child_process';
|
11 |
| -import { existsSync, mkdtempSync, readFileSync, realpathSync } from 'fs'; |
| 11 | +import { existsSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from 'fs'; |
12 | 12 | import { tmpdir } from 'os';
|
13 | 13 | import { join, resolve } from 'path';
|
14 | 14 | import * as rimraf from 'rimraf';
|
@@ -78,6 +78,22 @@ export function installTempPackage(
|
78 | 78 | } catch {}
|
79 | 79 | });
|
80 | 80 |
|
| 81 | + // NPM will warn when a `package.json` is not found in the install directory |
| 82 | + // Example: |
| 83 | + // npm WARN enoent ENOENT: no such file or directory, open '/tmp/.ng-temp-packages-84Qi7y/package.json' |
| 84 | + // npm WARN .ng-temp-packages-84Qi7y No description |
| 85 | + // npm WARN .ng-temp-packages-84Qi7y No repository field. |
| 86 | + // npm WARN .ng-temp-packages-84Qi7y No license field. |
| 87 | + |
| 88 | + // While we can use `npm init -y` we will end up needing to update the 'package.json' anyways |
| 89 | + // because of missing fields. |
| 90 | + writeFileSync(join(tempPath, 'package.json'), JSON.stringify({ |
| 91 | + name: 'temp-cli-install', |
| 92 | + description: 'temp-cli-install', |
| 93 | + repository: 'temp-cli-install', |
| 94 | + license: 'MIT', |
| 95 | + })); |
| 96 | + |
81 | 97 | // setup prefix/global modules path
|
82 | 98 | const packageManagerArgs = getPackageManagerArguments(packageManager);
|
83 | 99 | const tempNodeModules = join(tempPath, 'node_modules');
|
|
0 commit comments