-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/cli): handle NPM_CONFIG environment variables during ng …
…update and ng add Some organizations are moving away from storing tokens/secrets in an NPM config file in favor of environment variables that only exist for the span of a terminal session. This commit will make sure those variables are read even when there is no NPM config file present.
- Loading branch information
1 parent
02cc9c0
commit 6b00d12
Showing
6 changed files
with
150 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expectFileNotToExist, expectFileToExist } from '../../../utils/fs'; | ||
import { getActivePackageManager } from '../../../utils/packages'; | ||
import { git, ng } from '../../../utils/process'; | ||
import { | ||
createNpmConfigForAuthentication, | ||
setNpmEnvVarsForAuthentication, | ||
} from '../../../utils/registry'; | ||
|
||
export default async function () { | ||
const packageManager = getActivePackageManager(); | ||
|
||
if (packageManager === 'npm') { | ||
const originalEnvironment = { ...process.env }; | ||
try { | ||
const command = ['add', '@angular/pwa', '--skip-confirmation']; | ||
|
||
// Environment variables only | ||
await expectFileNotToExist('src/manifest.webmanifest'); | ||
setNpmEnvVarsForAuthentication(); | ||
await ng(...command); | ||
await expectFileToExist('src/manifest.webmanifest'); | ||
await git('clean', '-dxf'); | ||
|
||
// Mix of config file and env vars works | ||
await expectFileNotToExist('src/manifest.webmanifest'); | ||
await createNpmConfigForAuthentication(false, true); | ||
await ng(...command); | ||
await expectFileToExist('src/manifest.webmanifest'); | ||
} finally { | ||
process.env = originalEnvironment; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters