mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-06 15:07:27 -04:00
fix: create node_modules when writing node_modules/.shrinkwrap.yaml
This commit is contained in:
@@ -32,13 +32,14 @@ export function writeWantedOnly (
|
||||
return writeShrinkwrap(WANTED_SHRINKWRAP_FILENAME, pkgPath, wantedShrinkwrap, opts)
|
||||
}
|
||||
|
||||
export function writeCurrentOnly (
|
||||
export async function writeCurrentOnly (
|
||||
pkgPath: string,
|
||||
currentShrinkwrap: Shrinkwrap,
|
||||
opts?: {
|
||||
forceSharedFormat?: boolean,
|
||||
},
|
||||
) {
|
||||
await mkdirp(path.join(pkgPath, 'node_modules'))
|
||||
return writeShrinkwrap(CURRENT_SHRINKWRAP_FILENAME, pkgPath, currentShrinkwrap, opts)
|
||||
}
|
||||
|
||||
@@ -146,7 +147,10 @@ export default function write (
|
||||
if (wantedShrinkwrap === currentShrinkwrap) {
|
||||
return Promise.all([
|
||||
writeFileAtomic(wantedShrinkwrapPath, yamlDoc),
|
||||
mkdirp(path.dirname(currentShrinkwrapPath)).then(() => writeFileAtomic(currentShrinkwrapPath, yamlDoc)),
|
||||
(async () => {
|
||||
await mkdirp(path.dirname(currentShrinkwrapPath))
|
||||
await writeFileAtomic(currentShrinkwrapPath, yamlDoc)
|
||||
})(),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -159,6 +163,9 @@ export default function write (
|
||||
|
||||
return Promise.all([
|
||||
writeFileAtomic(wantedShrinkwrapPath, yamlDoc),
|
||||
mkdirp(path.dirname(currentShrinkwrapPath)).then(() => writeFileAtomic(currentShrinkwrapPath, currentYamlDoc)),
|
||||
(async () => {
|
||||
await mkdirp(path.dirname(currentShrinkwrapPath))
|
||||
await writeFileAtomic(currentShrinkwrapPath, currentYamlDoc)
|
||||
})(),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -150,7 +150,6 @@ test('writeCurrentOnly()', async t => {
|
||||
registry: 'https://registry.npmjs.org',
|
||||
shrinkwrapVersion: 3,
|
||||
}
|
||||
await mkdirp(path.join(projectPath, 'node_modules'))
|
||||
await writeCurrentOnly(projectPath, wantedShrinkwrap)
|
||||
t.equal(await readWanted(projectPath, { ignoreIncompatible: false }), null)
|
||||
t.deepEqual(await readCurrent(projectPath, { ignoreIncompatible: false }), wantedShrinkwrap)
|
||||
|
||||
Reference in New Issue
Block a user