Skip to content

Commit

Permalink
Resolve config depenencies via npmcli/config module
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Jun 9, 2023
1 parent 05070d1 commit 8f2b636
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions lib/ui5Framework/npm/Registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,17 @@ class Registry {
async _getPacoteOptions() {
if (!this._npmConfig) {
const {default: Config} = await import("@npmcli/config");
const {typeDefs} = Config;
const {
default: {flatten, definitions, shorthands},
defaults,
} = await import("@npmcli/config/lib/definitions");

const configuration = new Config({
// Merge collected data. Done in impure manner- need to alter the
// "output" param
flatten: (input, output) => {
for (const [key, value] of Object.entries(input)) {
output[key] = output[key] || value;
}
},
// Provided values- the ones we already know (with type validation)
definitions: {
cwd: {
default: this._cwd,
type: typeDefs.path
},
cache: {
default: this._cacheDir,
type: typeDefs.path
}
},
npmPath: this._cwd, // Used to read project's config
cwd: this._cwd // Used internally to derive the configuration
npmPath: this._cwd,
definitions,
flatten,
shorthands,
defaults
});

await configuration.load(); // Reads through the configurations
Expand Down

0 comments on commit 8f2b636

Please sign in to comment.