mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-24 10:01:48 -04:00
@@ -88,6 +88,7 @@
|
||||
"@zkochan/husky": "^0.0.0",
|
||||
"anonymous-npm-registry-client": "^0.1.2",
|
||||
"caw": "^2.0.0",
|
||||
"deep-require-cwd": "^1.0.0",
|
||||
"execa": "^0.9.0",
|
||||
"exists-link": "^2.0.0",
|
||||
"isexe": "^2.0.0",
|
||||
|
||||
@@ -64,6 +64,7 @@ devDependencies:
|
||||
'@zkochan/husky': 0.0.0
|
||||
anonymous-npm-registry-client: 0.1.2
|
||||
caw: 2.0.1
|
||||
deep-require-cwd: 1.0.0
|
||||
execa: 0.9.0
|
||||
exists-link: 2.0.0
|
||||
isexe: 2.0.0
|
||||
@@ -1915,6 +1916,24 @@ packages:
|
||||
node: '>=0.12.0'
|
||||
resolution:
|
||||
integrity: sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=
|
||||
/deep-require-cwd/1.0.0:
|
||||
dependencies:
|
||||
deep-require-from: 1.0.0
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha1-ZWmitmyT7mBlQ2dufUhqk6H3aXc=
|
||||
/deep-require-from/1.0.0:
|
||||
dependencies:
|
||||
deep-resolve-from: 1.1.0
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha1-BkXTXGy+BjfNQisYdps7HnJG3Yk=
|
||||
/deep-resolve-from/1.1.0:
|
||||
dependencies:
|
||||
resolve-from: 3.0.0
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha1-ghlR7I3zWdul9hXzXXa+XJ1Y9Oc=
|
||||
/defaults/1.0.3:
|
||||
dependencies:
|
||||
clone: 1.0.3
|
||||
@@ -7179,6 +7198,7 @@ specifiers:
|
||||
chalk: ^2.2.0
|
||||
common-tags: ^1.4.0
|
||||
cross-spawn: ^5.0.0
|
||||
deep-require-cwd: ^1.0.0
|
||||
delay: ^2.0.0
|
||||
diable: ^4.0.1
|
||||
execa: ^0.9.0
|
||||
|
||||
@@ -199,7 +199,6 @@ async function run (argv: string[]) {
|
||||
if (opts.only === 'prod' || opts.only === 'production' || !opts.only && opts.production) {
|
||||
opts.production = true
|
||||
opts.development = false
|
||||
opts.optional = true
|
||||
} else if (opts.only === 'dev' || opts.only === 'development') {
|
||||
opts.production = false
|
||||
opts.development = true
|
||||
@@ -207,7 +206,6 @@ async function run (argv: string[]) {
|
||||
} else {
|
||||
opts.production = true
|
||||
opts.development = true
|
||||
opts.optional = true
|
||||
}
|
||||
|
||||
const reporterType: ReporterType = (() => {
|
||||
|
||||
@@ -4,3 +4,4 @@ import './lifecycleScripts'
|
||||
import './hooks'
|
||||
import './preferOffline'
|
||||
import './sideEffects'
|
||||
import './optional'
|
||||
|
||||
@@ -11,23 +11,16 @@ import {
|
||||
|
||||
const basicPackageJson = loadJsonFile.sync(path.join(__dirname, '../utils/simple-package.json'))
|
||||
const test = promisifyTape(tape)
|
||||
test.only = promisifyTape(tape.only)
|
||||
|
||||
test('production install (with --production flag)', async (t: tape.Test) => {
|
||||
const project = prepare(t, basicPackageJson)
|
||||
|
||||
await execPnpm('install', '--production')
|
||||
|
||||
const rimrafDir = fs.statSync(path.resolve('node_modules', 'rimraf'))
|
||||
|
||||
let tapStatErrCode: number = 0
|
||||
try {
|
||||
fs.statSync(path.resolve('node_modules', '@rstacruz'))
|
||||
} catch (err) {
|
||||
tapStatErrCode = err.code
|
||||
}
|
||||
|
||||
t.ok(rimrafDir.isSymbolicLink, 'rimraf exists')
|
||||
t.is(tapStatErrCode, 'ENOENT', 'tap-spec does not exist')
|
||||
await project.hasNot('@rstacruze/tap-spect')
|
||||
await project.has('rimraf')
|
||||
await project.has('is-positive')
|
||||
})
|
||||
|
||||
test('production install (with production NODE_ENV)', async (t: tape.Test) => {
|
||||
@@ -40,15 +33,9 @@ test('production install (with production NODE_ENV)', async (t: tape.Test) => {
|
||||
// reset NODE_ENV
|
||||
process.env.NODE_ENV = originalNodeEnv
|
||||
|
||||
const rimrafDir = fs.statSync(path.resolve('node_modules', 'rimraf'))
|
||||
|
||||
let tapStatErrCode: number = 0
|
||||
try {
|
||||
fs.statSync(path.resolve('node_modules', '@rstacruz'))
|
||||
} catch (err) { tapStatErrCode = err.code }
|
||||
|
||||
t.ok(rimrafDir.isSymbolicLink, 'rimraf exists')
|
||||
t.is(tapStatErrCode, 'ENOENT', 'tap-spec does not exist')
|
||||
await project.hasNot('@rstacruze/tap-spect')
|
||||
await project.has('rimraf')
|
||||
await project.has('is-positive')
|
||||
})
|
||||
|
||||
test('install dev dependencies only', async (t: tape.Test) => {
|
||||
|
||||
53
test/install/optional.ts
Normal file
53
test/install/optional.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import path = require('path')
|
||||
import fs = require('mz/fs')
|
||||
import tape = require('tape')
|
||||
import loadJsonFile = require('load-json-file')
|
||||
import promisifyTape from 'tape-promise'
|
||||
import deepRequireCwd = require('deep-require-cwd')
|
||||
import {
|
||||
prepare,
|
||||
testDefaults,
|
||||
execPnpm,
|
||||
} from '../utils'
|
||||
|
||||
const basicPackageJson = loadJsonFile.sync(path.join(__dirname, '../utils/simple-package.json'))
|
||||
const test = promisifyTape(tape)
|
||||
test.only = promisifyTape(tape.only)
|
||||
|
||||
test('installing optional dependencies when --no-optional is not used', async (t: tape.Test) => {
|
||||
const project = prepare(t, {
|
||||
dependencies: {
|
||||
'pkg-with-good-optional': '*',
|
||||
},
|
||||
optionalDependencies: {
|
||||
'is-positive': '1.0.0',
|
||||
},
|
||||
})
|
||||
|
||||
await execPnpm('install')
|
||||
|
||||
await project.has('is-positive')
|
||||
await project.has('pkg-with-good-optional')
|
||||
|
||||
t.ok(deepRequireCwd(['pkg-with-good-optional', 'dep-of-pkg-with-1-dep', './package.json']))
|
||||
t.ok(deepRequireCwd(['pkg-with-good-optional', 'is-positive', './package.json']), 'optional subdep installed')
|
||||
})
|
||||
|
||||
test('not installing optional dependencies when --no-optional is used', async (t: tape.Test) => {
|
||||
const project = prepare(t, {
|
||||
dependencies: {
|
||||
'pkg-with-good-optional': '*',
|
||||
},
|
||||
optionalDependencies: {
|
||||
'is-positive': '1.0.0',
|
||||
},
|
||||
})
|
||||
|
||||
await execPnpm('install', '--no-optional')
|
||||
|
||||
await project.hasNot('is-positive')
|
||||
await project.has('pkg-with-good-optional')
|
||||
|
||||
t.ok(deepRequireCwd(['pkg-with-good-optional', 'dep-of-pkg-with-1-dep', './package.json']))
|
||||
t.notOk(deepRequireCwd.silent(['pkg-with-good-optional', 'is-positive', './package.json']), 'optional subdep not installed')
|
||||
})
|
||||
@@ -6,5 +6,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rstacruz/tap-spec": "~4.1.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"is-positive": "1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user