feat!: ignore the NODE_ENV env variable (#8839)

close #8827
This commit is contained in:
Zoltan Kochan
2024-12-15 20:24:51 +01:00
committed by GitHub
parent fb9e3b4ee0
commit ac5b9d8e16
7 changed files with 12 additions and 34 deletions

View File

@@ -0,0 +1,9 @@
---
"@pnpm/plugin-commands-installation": major
"@pnpm/plugin-commands-deploy": major
"@pnpm/default-reporter": major
"@pnpm/config": major
"pnpm": major
---
All dependencies are installed even when the `NODE_ENV` environment variable is set to `production [#8827](https://github.com/pnpm/pnpm/issues/8827).

View File

@@ -79,9 +79,6 @@ export function reportSummary (
} else if (CONFIG_BY_DEP_TYPE[depType] && opts.pnpmConfig?.[CONFIG_BY_DEP_TYPE[depType]] === false) {
msg += EOL
msg += `${chalk.cyanBright(`${propertyByDependencyType[depType] as string}:`)} skipped`
if (opts.env.NODE_ENV === 'production' && depType === 'dev') {
msg += ' because NODE_ENV is set to production'
}
msg += EOL
}
}

View File

@@ -604,7 +604,7 @@ ${ADD} bar ${versionColor('2.0.0')}
${h1('optionalDependencies:')} skipped
${h1('devDependencies:')} skipped because NODE_ENV is set to production
${h1('devDependencies:')} skipped
`)
},
})

View File

@@ -335,15 +335,6 @@ export async function getConfig (opts: {
pnpmConfig.packageManager = packageManager
if (env.NODE_ENV) {
if (cliOptions.production) {
pnpmConfig.only = 'production'
}
if (cliOptions.dev) {
pnpmConfig.only = 'dev'
}
}
if (pnpmConfig.only === 'prod' || pnpmConfig.only === 'production' || !pnpmConfig.only && pnpmConfig.production) {
pnpmConfig.production = true
pnpmConfig.dev = false

View File

@@ -110,7 +110,7 @@ For options that may be used with `-r`, see "pnpm help recursive"',
shortAlias: '-P',
},
{
description: 'Only `devDependencies` are installed regardless of the `NODE_ENV`',
description: 'Only `devDependencies` are installed',
name: '--dev',
shortAlias: '-D',
},

View File

@@ -16,25 +16,6 @@ test('production install (with --production flag)', async () => {
project.has('is-positive')
})
test('production install (with production NODE_ENV)', async () => {
const project = prepare(basicPackageManifest)
await execPnpm(['install'], { env: { NODE_ENV: 'production' } })
project.hasNot(Object.keys(basicPackageManifest.devDependencies!)[0])
project.has('rimraf')
project.has('is-positive')
})
test('dev dependencies install (with production NODE_ENV)', async () => {
const project = prepare(basicPackageManifest)
await execPnpm(['install', '--dev'], { env: { NODE_ENV: 'production' } })
project.hasNot(Object.keys(basicPackageManifest.dependencies!)[0])
project.has('@rstacruz/tap-spec')
})
test('install dev dependencies only', async () => {
const project = prepare({
dependencies: {

View File

@@ -40,7 +40,7 @@ export function help (): string {
shortAlias: '-P',
},
{
description: 'Only `devDependencies` are installed regardless of the `NODE_ENV`',
description: 'Only `devDependencies` are installed',
name: '--dev',
shortAlias: '-D',
},