fix(testing): fix migration path error on windows (#9969)

This commit is contained in:
Caleb Ukle 2022-04-22 23:07:45 -05:00 committed by GitHub
parent 88971468db
commit 1297f0616a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import { import {
formatFiles, formatFiles,
joinPathFragments,
logger, logger,
offsetFromRoot, offsetFromRoot,
ProjectConfiguration, ProjectConfiguration,
@ -39,7 +40,10 @@ function updateJestPreset(
tree, tree,
options.jestConfig, options.jestConfig,
'preset', 'preset',
join(offsetFromRoot(dirname(options.jestConfig)), 'jest.preset.ts'), joinPathFragments(
offsetFromRoot(dirname(options.jestConfig)),
'jest.preset.ts'
),
{ valueAsString: false } { valueAsString: false }
); );
} }
@ -79,7 +83,7 @@ function updateTsconfigSpec(
projectConfig: ProjectConfiguration, projectConfig: ProjectConfiguration,
path path
) { ) {
updateJson(tree, join(projectConfig.root, path), (json) => { updateJson(tree, joinPathFragments(projectConfig.root, path), (json) => {
json.include = Array.from( json.include = Array.from(
new Set([...(json.include || []), 'jest.config.ts']) new Set([...(json.include || []), 'jest.config.ts'])
); );
@ -115,7 +119,7 @@ export async function updateJestConfigExt(tree: Tree) {
const rootFiles = tree.children(projectConfig.root); const rootFiles = tree.children(projectConfig.root);
for (const fileName of rootFiles) { for (const fileName of rootFiles) {
if (fileName === 'tsconfig.json') { if (fileName === 'tsconfig.json') {
const filePath = join(projectConfig.root, fileName); const filePath = joinPathFragments(projectConfig.root, fileName);
const tsConfig = readJson(tree, filePath); const tsConfig = readJson(tree, filePath);
if (tsConfig.references) { if (tsConfig.references) {
@ -125,7 +129,7 @@ export async function updateJestConfigExt(tree: Tree) {
continue; continue;
} }
updateTsConfig(tree, join(projectConfig.root, path)); updateTsConfig(tree, joinPathFragments(projectConfig.root, path));
} }
} else { } else {
updateTsConfig(tree, filePath); updateTsConfig(tree, filePath);