mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-05 22:47:50 -04:00
fix: lock the store by default
This commit is contained in:
@@ -86,6 +86,7 @@ export default async (
|
||||
const npmConfig = loadNpmConf(cliArgs, types, {
|
||||
'bail': true,
|
||||
'globalconfig': npmDefaults.globalconfig,
|
||||
'lock': true,
|
||||
'package-lock': npmDefaults['package-lock'],
|
||||
'prefix': npmDefaults.prefix,
|
||||
'registry': npmDefaults.registry,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import {install, installPkgs} from 'supi'
|
||||
import {StoreController} from 'package-store'
|
||||
import {
|
||||
install,
|
||||
InstallOptions,
|
||||
installPkgs,
|
||||
} from 'supi'
|
||||
import createStoreController from '../createStoreController'
|
||||
import requireHooks from '../requireHooks'
|
||||
import {PnpmOptions} from '../types'
|
||||
@@ -10,7 +15,10 @@ import {PnpmOptions} from '../types'
|
||||
*/
|
||||
export default async function installCmd (
|
||||
input: string[],
|
||||
opts: PnpmOptions,
|
||||
opts: PnpmOptions & {
|
||||
store?: string,
|
||||
storeController?: StoreController,
|
||||
},
|
||||
) {
|
||||
// `pnpm install ""` is going to be just `pnpm install`
|
||||
input = input.filter(Boolean)
|
||||
@@ -20,11 +28,17 @@ export default async function installCmd (
|
||||
opts.hooks = requireHooks(prefix, opts)
|
||||
}
|
||||
|
||||
const store = await createStoreController(opts)
|
||||
const installOpts = Object.assign(opts, {
|
||||
store: store.path,
|
||||
storeController: store.ctrl,
|
||||
})
|
||||
const installOpts = (
|
||||
opts.storeController && opts.store
|
||||
? opts
|
||||
: await (async () => {
|
||||
const store = await createStoreController(opts)
|
||||
return Object.assign(opts, {
|
||||
store: store.path,
|
||||
storeController: store.ctrl,
|
||||
})
|
||||
})()
|
||||
) as InstallOptions
|
||||
|
||||
if (!input || !input.length) {
|
||||
return install(installOpts)
|
||||
|
||||
@@ -54,10 +54,17 @@ export default async (
|
||||
globalPkgNames.forEach((pkgName) => pkgPaths.push(path.join(globalPkgPath, 'node_modules', pkgName)))
|
||||
}
|
||||
|
||||
// TODO: allow the linked packages to use different stores
|
||||
await Promise.all(
|
||||
pkgPaths.map((prefix) => installLimit(async () =>
|
||||
await install([], await getConfigs({...opts.cliArgs, prefix}, {excludeReporter: true})),
|
||||
await install([], {
|
||||
...await getConfigs({...opts.cliArgs, prefix}, {excludeReporter: true}),
|
||||
store: linkOpts.store,
|
||||
storeController: linkOpts.storeController,
|
||||
}),
|
||||
)),
|
||||
)
|
||||
await link(pkgPaths, path.join(cwd, 'node_modules'), linkOpts)
|
||||
|
||||
await linkOpts.storeController.close()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import createFetcher from '@pnpm/default-fetcher'
|
||||
import createResolver from '@pnpm/default-resolver'
|
||||
import { StrictPnpmOptions } from '@pnpm/types'
|
||||
import LRU = require('lru-cache')
|
||||
import createStore from 'package-store'
|
||||
import path = require('path')
|
||||
@@ -9,7 +8,7 @@ export default async (
|
||||
opts: {
|
||||
registry?: string,
|
||||
rawNpmConfig: object,
|
||||
lock?: boolean,
|
||||
lock: boolean,
|
||||
store: string,
|
||||
alwaysAuth?: boolean,
|
||||
strictSsl?: boolean,
|
||||
@@ -31,6 +30,7 @@ export default async (
|
||||
packageImportMethod?: 'auto' | 'hardlink' | 'copy' | 'reflink',
|
||||
},
|
||||
) => {
|
||||
// TODO: either print a warning or just log if --no-lock is used
|
||||
const sopts = Object.assign(opts, {
|
||||
locks: opts.lock ? path.join(opts.store, '_locks') : undefined,
|
||||
registry: opts.registry || 'https://registry.npmjs.org/',
|
||||
|
||||
@@ -2,7 +2,6 @@ import logger from '@pnpm/logger'
|
||||
import {connectStoreController} from '@pnpm/server'
|
||||
import storePath from '@pnpm/store-path'
|
||||
import delay = require('delay')
|
||||
import loadJsonFile = require('load-json-file')
|
||||
import fs = require('mz/fs')
|
||||
import {StoreController} from 'package-store'
|
||||
import path = require('path')
|
||||
@@ -30,7 +29,7 @@ export default async function (
|
||||
userAgent?: string,
|
||||
ignoreFile?: (filename: string) => boolean,
|
||||
offline?: boolean,
|
||||
lock?: boolean,
|
||||
lock: boolean,
|
||||
lockStaleDuration?: number,
|
||||
networkConcurrency?: number,
|
||||
store?: string,
|
||||
|
||||
@@ -63,7 +63,7 @@ export interface PnpmOptions {
|
||||
networkConcurrency?: number,
|
||||
fetchingConcurrency?: number,
|
||||
lockStaleDuration?: number,
|
||||
lock?: boolean,
|
||||
lock: boolean,
|
||||
childConcurrency?: number,
|
||||
repeatInstallDepth?: number,
|
||||
ignorePnpmfile?: boolean,
|
||||
|
||||
@@ -9,7 +9,6 @@ import writePkg = require('write-pkg')
|
||||
import {
|
||||
pathToLocalPkg,
|
||||
prepare,
|
||||
testDefaults,
|
||||
execPnpm,
|
||||
} from './utils'
|
||||
import fs = require('mz/fs')
|
||||
|
||||
Reference in New Issue
Block a user