-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: handle parallel installs * build: skip unnecessary shims
- Loading branch information
Showing
15 changed files
with
184 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
export async function mutex<T>(p: string, cb: () => Promise<T>) { | ||
return await cb(); | ||
import fs from 'fs'; | ||
|
||
export async function rimraf(path: string) { | ||
const [major, minor] = process.versions.node.split(`.`).map(section => Number(section)); | ||
|
||
if (major > 14 || (major === 14 && minor >= 14)) { | ||
// rm was added in v14.14.0 | ||
return fs.promises.rm(path, {recursive: true}); | ||
} else if (major > 12 || (major === 12 && minor >= 10)) { | ||
// rmdir got support for recursive in v12.10.0 and was deprecated in v14.14.0 | ||
return fs.promises.rmdir(path, {recursive: true}); | ||
} else { | ||
const rimraf = await import(`rimraf`); | ||
return new Promise<void>((resolve, reject) => { | ||
rimraf.default(path, err => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,3 +328,30 @@ it(`should support running package managers with bin array`, async () => { | |
}); | ||
}); | ||
}); | ||
|
||
it(`should handle parallel installs`, async () => { | ||
await xfs.mktempPromise(async cwd => { | ||
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { | ||
packageManager: `[email protected]`, | ||
}); | ||
|
||
await expect(Promise.all([ | ||
runCli(cwd, [`yarn`, `--version`]), | ||
runCli(cwd, [`yarn`, `--version`]), | ||
runCli(cwd, [`yarn`, `--version`]), | ||
])).resolves.toMatchObject([ | ||
{ | ||
stdout: `2.2.2\n`, | ||
exitCode: 0, | ||
}, | ||
{ | ||
stdout: `2.2.2\n`, | ||
exitCode: 0, | ||
}, | ||
{ | ||
stdout: `2.2.2\n`, | ||
exitCode: 0, | ||
}, | ||
]); | ||
}); | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.