source: trip-planner-front/node_modules/@npmcli/run-script/lib/package-envs.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 683 bytes
Line 
1// https://github.com/npm/rfcs/pull/183
2
3const envVal = val => Array.isArray(val) ? val.map(v => envVal(v)).join('\n\n')
4 : val === null || val === false ? ''
5 : String(val)
6
7const packageEnvs = (env, vals, prefix) => {
8 for (const [key, val] of Object.entries(vals)) {
9 if (val === undefined)
10 continue
11 else if (val && !Array.isArray(val) && typeof val === 'object')
12 packageEnvs(env, val, `${prefix}${key}_`)
13 else
14 env[`${prefix}${key}`] = envVal(val)
15 }
16 return env
17}
18
19module.exports = (env, pkg) => packageEnvs({ ...env }, {
20 name: pkg.name,
21 version: pkg.version,
22 config: pkg.config,
23 engines: pkg.engines,
24 bin: pkg.bin,
25}, 'npm_package_')
Note: See TracBrowser for help on using the repository browser.