зеркало из https://github.com/microsoft/rushstack.git
[rush-resolver-cache] Fix Windows compatibility (#4909)
Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
This commit is contained in:
Родитель
c4ed903c2b
Коммит
6cf823c14a
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@microsoft/rush",
|
||||
"comment": "Fix Windows compatibility for `@rushstack/rush-resolver-cache-plugin`.",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "@microsoft/rush"
|
||||
}
|
|
@ -144,14 +144,12 @@ export interface IComputeResolverCacheFromLockfileOptions {
|
|||
export async function computeResolverCacheFromLockfileAsync(
|
||||
params: IComputeResolverCacheFromLockfileOptions
|
||||
): Promise<IResolverCacheFile> {
|
||||
const {
|
||||
workspaceRoot,
|
||||
commonPrefixToTrim,
|
||||
platformInfo,
|
||||
projectByImporterPath,
|
||||
lockfile,
|
||||
afterExternalPackagesAsync
|
||||
} = params;
|
||||
const { platformInfo, projectByImporterPath, lockfile, afterExternalPackagesAsync } = params;
|
||||
// Needs to be normalized to `/` for path.posix.join to work correctly
|
||||
const workspaceRoot: string = params.workspaceRoot.replace(/\\/g, '/');
|
||||
// Needs to be normalized to `/` for path.posix.join to work correctly
|
||||
const commonPrefixToTrim: string = params.commonPrefixToTrim.replace(/\\/g, '/');
|
||||
|
||||
const contexts: Map<string, IResolverContext> = new Map();
|
||||
const missingOptionalDependencies: Set<string> = new Set();
|
||||
|
||||
|
|
|
@ -23,13 +23,15 @@ interface ITestCase {
|
|||
|
||||
const TEST_CASES: readonly ITestCase[] = [
|
||||
{
|
||||
// Validate with POSIX-style path inputs
|
||||
workspaceRoot: '/$root/common/temp/build-tests',
|
||||
commonPrefixToTrim: '/$root/',
|
||||
lockfileName: 'build-tests-subspace.yaml'
|
||||
},
|
||||
{
|
||||
workspaceRoot: '/$root/common/temp/default',
|
||||
commonPrefixToTrim: '/$root/',
|
||||
// Validate that it works with Windows-style path inputs
|
||||
workspaceRoot: '\\$root\\common\\temp\\default',
|
||||
commonPrefixToTrim: '\\$root\\',
|
||||
lockfileName: 'default-subspace.yaml'
|
||||
},
|
||||
{
|
||||
|
@ -105,7 +107,7 @@ describe(computeResolverCacheFromLockfileAsync.name, () => {
|
|||
for (const importerPath of lockfile.importers.keys()) {
|
||||
const remainder: string = importerPath.slice(importerPath.lastIndexOf('../') + 3);
|
||||
projectByImporterPath.setItem(importerPath, {
|
||||
projectFolder: `${commonPrefixToTrim}${remainder}`,
|
||||
projectFolder: `${commonPrefixToTrim.replace(/\\/g, '/')}${remainder}`,
|
||||
packageJson: {
|
||||
name: `@local/${remainder.replace(/\//g, '+')}`
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче