Skip to content

Commit 2421a59

Browse files
committed
fix(assets): Fix assets copying on Windows
Fix issue where Nest CLI fails to copy assets files on Windows due to path format
1 parent 185169a commit 2421a59

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/compiler/assets-manager.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as chokidar from 'chokidar';
1+
import * as chokidar from 'chokidar';
22
import { statSync } from 'fs';
33
import { sync } from 'glob';
44
import { dirname, join, sep } from 'path';
@@ -60,18 +60,18 @@ export class AssetsManager {
6060
sourceRoot = join(process.cwd(), sourceRoot);
6161

6262
const filesToCopy = assets.map<AssetEntry>((item) => {
63-
if (typeof item === 'string') {
64-
return {
65-
glob: join(sourceRoot, item),
66-
outDir,
67-
};
68-
}
63+
let includePath = typeof item === 'string' ? item : item.include!;
64+
let excludePath = typeof item !== 'string' && item.exclude ? item.exclude : undefined;
65+
66+
includePath = join(sourceRoot, includePath).replace(/\\/g, '/');
67+
excludePath = excludePath ? join(sourceRoot, excludePath).replace(/\\/g, '/') : undefined;
68+
6969
return {
70-
outDir: item.outDir || outDir,
71-
glob: join(sourceRoot, item.include!),
72-
exclude: item.exclude ? join(sourceRoot, item.exclude) : undefined,
73-
flat: item.flat, // deprecated field
74-
watchAssets: item.watchAssets,
70+
outDir: typeof item !== 'string' ? item.outDir || outDir : outDir,
71+
glob: includePath,
72+
exclude: excludePath,
73+
flat: typeof item !== 'string' ? item.flat : undefined, // deprecated field
74+
watchAssets: typeof item !== 'string' ? item.watchAssets : undefined,
7575
};
7676
});
7777

@@ -104,6 +104,7 @@ export class AssetsManager {
104104
const files = sync(item.glob, { ignore: item.exclude }).filter(
105105
(matched) => statSync(matched).isFile(),
106106
);
107+
107108
for (const path of files) {
108109
this.actionOnFile({ ...option, path, action: 'change' });
109110
}

0 commit comments

Comments
 (0)