PHP 8.2.30
Preview: package-envs.js Size: 826 B
//opt/alt/alt-nodejs22/root/usr/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/package-envs.js

const packageEnvs = (vals, prefix, env = {}) => {
  for (const [key, val] of Object.entries(vals)) {
    if (val === undefined) {
      continue
    } else if (val === null || val === false) {
      env[`${prefix}${key}`] = ''
    } else if (Array.isArray(val)) {
      val.forEach((item, index) => {
        packageEnvs({ [`${key}_${index}`]: item }, `${prefix}`, env)
      })
    } else if (typeof val === 'object') {
      packageEnvs(val, `${prefix}${key}_`, env)
    } else {
      env[`${prefix}${key}`] = String(val)
    }
  }
  return env
}

// https://github.com/npm/rfcs/pull/183 defines which fields we put into the environment
module.exports = pkg => {
  return packageEnvs({
    name: pkg.name,
    version: pkg.version,
    config: pkg.config,
    engines: pkg.engines,
    bin: pkg.bin,
  }, 'npm_package_')
}

Directory Contents

Dirs: 1 × Files: 8

Name Size Perms Modified Actions
- drwxr-xr-x 2026-03-14 07:02:09
Edit Download
245 B lrw-r--r-- 2026-02-23 06:54:00
Edit Download
1.10 KB lrw-r--r-- 2026-02-23 06:54:00
Edit Download
826 B lrw-r--r-- 2026-02-23 06:54:00
Edit Download
2.91 KB lrw-r--r-- 2026-02-23 06:54:00
Edit Download
520 B lrw-r--r-- 2026-02-23 06:54:00
Edit Download
1.47 KB lrw-r--r-- 2026-02-23 06:54:00
Edit Download
1.03 KB lrw-r--r-- 2026-02-23 06:54:00
Edit Download
1.18 KB lrw-r--r-- 2026-02-23 06:54:00
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).