|
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'; |
@@ -72,6 +72,22 @@ export function installTempPackage( |
72 | 72 | } catch {} |
73 | 73 | }); |
74 | 74 |
|
| 75 | + // NPM will warn when a `package.json` is not found in the install directory |
| 76 | + // Example: |
| 77 | + // npm WARN enoent ENOENT: no such file or directory, open '/tmp/.ng-temp-packages-84Qi7y/package.json' |
| 78 | + // npm WARN .ng-temp-packages-84Qi7y No description |
| 79 | + // npm WARN .ng-temp-packages-84Qi7y No repository field. |
| 80 | + // npm WARN .ng-temp-packages-84Qi7y No license field. |
| 81 | + |
| 82 | + // While we can use `npm init -y` we will end up needing to update the 'package.json' anyways |
| 83 | + // because of missing fields. |
| 84 | + writeFileSync(join(tempPath, 'package.json'), JSON.stringify({ |
| 85 | + name: 'temp-cli-install', |
| 86 | + description: 'temp-cli-install', |
| 87 | + repository: 'temp-cli-install', |
| 88 | + license: 'MIT', |
| 89 | + })); |
| 90 | + |
75 | 91 | // setup prefix/global modules path |
76 | 92 | const packageManagerArgs = getPackageManagerArguments(packageManager); |
77 | 93 | const tempNodeModules = join(tempPath, 'node_modules'); |
|
0 commit comments