-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replacing env variables to values in .npmrc (#5623)
- Loading branch information
Showing
11 changed files
with
102 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@pnpm/config": minor | ||
--- | ||
|
||
New function added: `readLocalConfig(dir: string)`. |
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,7 @@ | ||
--- | ||
"@pnpm/plugin-commands-installation": patch | ||
"@pnpm/plugin-commands-rebuild": patch | ||
"pnpm": patch | ||
--- | ||
|
||
Replace environment variable placeholders with their values, when reading `.npmrc` files in subdirectories inside a workspace [#2570](https://github.com/pnpm/pnpm/issues/2570). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import path from 'path' | ||
import camelcaseKeys from 'camelcase-keys' | ||
import { envReplace } from '@pnpm/config.env-replace' | ||
import readIniFile from 'read-ini-file' | ||
|
||
export async function readLocalConfig (prefix: string) { | ||
try { | ||
const ini = await readIniFile(path.join(prefix, '.npmrc')) as Record<string, string> | ||
const config = camelcaseKeys(ini) as (Record<string, string> & { hoist?: boolean }) | ||
if (config.shamefullyFlatten) { | ||
config.hoistPattern = '*' | ||
// TODO: print a warning | ||
} | ||
if (config.hoist === false) { | ||
config.hoistPattern = '' | ||
} | ||
for (const [key, val] of Object.entries(config)) { | ||
if (typeof val === 'string') { | ||
try { | ||
config[key] = envReplace(val, process.env) | ||
} catch (err) { | ||
// ignore | ||
} | ||
} | ||
} | ||
return config | ||
} catch (err: any) { // eslint-disable-line | ||
if (err.code !== 'ENOENT') throw err | ||
return {} | ||
} | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.