fix(devkit): move files to a directory using normalized paths to handle windows correctly (#7264)

This commit is contained in:
Leosvel Pérez Espinosa 2021-10-06 17:42:36 +01:00 committed by GitHub
parent 3881d002fe
commit c21835d40a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { Tree } from '@nrwl/tao/src/shared/tree';
import { relative } from 'path';
import { visitNotIgnoredFiles } from '../generators/visit-not-ignored-files';
import { normalizePath } from './path';
@ -11,7 +12,7 @@ export function moveFilesToNewDirectory(
newDir = normalizePath(newDir);
visitNotIgnoredFiles(tree, oldDir, (file) => {
try {
tree.rename(file, file.replace(oldDir, newDir));
tree.rename(file, `${newDir}/${relative(oldDir, file)}`);
} catch (e) {
if (!tree.exists(oldDir)) {
console.warn(`Path ${oldDir} does not exist`);