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)
|
to: classify(newProjectName)
|
||||||
};
|
};
|
||||||
|
|
||||||
const findModuleName = new RegExp(moduleName.from, 'g');
|
const findModuleName = new RegExp(`\\b${moduleName.from}`, 'g');
|
||||||
|
|
||||||
const moduleFile = {
|
const moduleFile = {
|
||||||
from: `${schema.projectName}.module`,
|
from: `${schema.projectName}.module`,
|
||||||
|
|||||||
@ -31,11 +31,11 @@ export function updateJestConfig(schema: Schema): Rule {
|
|||||||
|
|
||||||
const oldContent = tree.read(jestConfigPath).toString('utf-8');
|
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 findDir = new RegExp(project.root, 'g');
|
||||||
|
|
||||||
const newContent = oldContent
|
const newContent = oldContent
|
||||||
.replace(findName, newProjectName)
|
.replace(findName, `'${newProjectName}'`)
|
||||||
.replace(findDir, destination);
|
.replace(findDir, destination);
|
||||||
tree.overwrite(jestConfigPath, newContent);
|
tree.overwrite(jestConfigPath, newContent);
|
||||||
|
|
||||||
|
|||||||
@ -22,14 +22,14 @@ export function updateProjectRootFiles(schema: Schema): Rule {
|
|||||||
const project = workspace.projects.get(schema.projectName);
|
const project = workspace.projects.get(schema.projectName);
|
||||||
const destination = getDestination(schema, workspace);
|
const destination = getDestination(schema, workspace);
|
||||||
|
|
||||||
const newRelativeRoot = path.relative(
|
const newRelativeRoot = path
|
||||||
path.join(appRootPath, destination),
|
.relative(path.join(appRootPath, destination), appRootPath)
|
||||||
appRootPath
|
.split(path.sep)
|
||||||
);
|
.join('/');
|
||||||
const oldRelativeRoot = path.relative(
|
const oldRelativeRoot = path
|
||||||
path.join(appRootPath, project.root),
|
.relative(path.join(appRootPath, project.root), appRootPath)
|
||||||
appRootPath
|
.split(path.sep)
|
||||||
);
|
.join('/');
|
||||||
|
|
||||||
if (newRelativeRoot === oldRelativeRoot) {
|
if (newRelativeRoot === oldRelativeRoot) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
|||||||
@ -27,7 +27,10 @@ export function getDestination(
|
|||||||
if (projectType === 'application') {
|
if (projectType === 'application') {
|
||||||
rootFolder = 'apps';
|
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