fix(core): fix move schematic issues
Use slashes as path separator even when used on windows environments to avoid mis-identifying escaped characters in file path Use slash as path separator even when used on windows to get a correct path in extends property Fix an issue when renaming jest project name where substrings were replaced as well in the file Fix an issue when renaming imports where substrings in imports where replaced too
This commit is contained in:
parent
82e9a5627e
commit
df197cf194
@ -32,7 +32,7 @@ export function updateModuleName(schema: Schema) {
|
||||
to: classify(newProjectName)
|
||||
};
|
||||
|
||||
const findModuleName = new RegExp(moduleName.from, 'g');
|
||||
const findModuleName = new RegExp(`\\b${moduleName.from}`, 'g');
|
||||
|
||||
const moduleFile = {
|
||||
from: `${schema.projectName}.module`,
|
||||
|
||||
@ -31,11 +31,11 @@ export function updateJestConfig(schema: Schema): Rule {
|
||||
|
||||
const oldContent = tree.read(jestConfigPath).toString('utf-8');
|
||||
|
||||
const findName = new RegExp(schema.projectName, 'g');
|
||||
const findName = new RegExp(`'${schema.projectName}'`, 'g');
|
||||
const findDir = new RegExp(project.root, 'g');
|
||||
|
||||
const newContent = oldContent
|
||||
.replace(findName, newProjectName)
|
||||
.replace(findName, `'${newProjectName}'`)
|
||||
.replace(findDir, destination);
|
||||
tree.overwrite(jestConfigPath, newContent);
|
||||
|
||||
|
||||
@ -22,14 +22,14 @@ export function updateProjectRootFiles(schema: Schema): Rule {
|
||||
const project = workspace.projects.get(schema.projectName);
|
||||
const destination = getDestination(schema, workspace);
|
||||
|
||||
const newRelativeRoot = path.relative(
|
||||
path.join(appRootPath, destination),
|
||||
appRootPath
|
||||
);
|
||||
const oldRelativeRoot = path.relative(
|
||||
path.join(appRootPath, project.root),
|
||||
appRootPath
|
||||
);
|
||||
const newRelativeRoot = path
|
||||
.relative(path.join(appRootPath, destination), appRootPath)
|
||||
.split(path.sep)
|
||||
.join('/');
|
||||
const oldRelativeRoot = path
|
||||
.relative(path.join(appRootPath, project.root), appRootPath)
|
||||
.split(path.sep)
|
||||
.join('/');
|
||||
|
||||
if (newRelativeRoot === oldRelativeRoot) {
|
||||
// nothing to do
|
||||
|
||||
@ -27,7 +27,10 @@ export function getDestination(
|
||||
if (projectType === 'application') {
|
||||
rootFolder = 'apps';
|
||||
}
|
||||
return path.join(rootFolder, schema.destination);
|
||||
return path
|
||||
.join(rootFolder, schema.destination)
|
||||
.split(path.sep)
|
||||
.join('/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user