From 2421a59233f536b2bc3eb6f1f578a31a7551a8f6 Mon Sep 17 00:00:00 2001
From: Flavio Moreno <flavio.moreno941@gmail.com>
Date: Sun, 24 Mar 2024 18:38:22 +0100
Subject: [PATCH 1/2] fix(assets): Fix assets copying on Windows

Fix issue where Nest CLI fails to copy assets files on Windows due to path format
---
 lib/compiler/assets-manager.ts | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/lib/compiler/assets-manager.ts b/lib/compiler/assets-manager.ts
index d9defad48..6ef92c708 100644
--- a/lib/compiler/assets-manager.ts
+++ b/lib/compiler/assets-manager.ts
@@ -1,4 +1,4 @@
-import * as chokidar from 'chokidar';
+import * as   chokidar from 'chokidar';
 import { statSync } from 'fs';
 import { sync } from 'glob';
 import { dirname, join, sep } from 'path';
@@ -60,18 +60,18 @@ export class AssetsManager {
       sourceRoot = join(process.cwd(), sourceRoot);
 
       const filesToCopy = assets.map<AssetEntry>((item) => {
-        if (typeof item === 'string') {
-          return {
-            glob: join(sourceRoot, item),
-            outDir,
-          };
-        }
+        let includePath = typeof item === 'string' ? item : item.include!;
+        let excludePath = typeof item !== 'string' && item.exclude ? item.exclude : undefined;
+
+        includePath = join(sourceRoot, includePath).replace(/\\/g, '/');
+        excludePath = excludePath ? join(sourceRoot, excludePath).replace(/\\/g, '/') : undefined;
+
         return {
-          outDir: item.outDir || outDir,
-          glob: join(sourceRoot, item.include!),
-          exclude: item.exclude ? join(sourceRoot, item.exclude) : undefined,
-          flat: item.flat, // deprecated field
-          watchAssets: item.watchAssets,
+          outDir: typeof item !== 'string' ? item.outDir || outDir : outDir,
+          glob: includePath,
+          exclude: excludePath,
+          flat: typeof item !== 'string' ? item.flat : undefined, // deprecated field
+          watchAssets: typeof item !== 'string' ? item.watchAssets : undefined,
         };
       });
 
@@ -104,6 +104,7 @@ export class AssetsManager {
           const files = sync(item.glob, { ignore: item.exclude }).filter(
             (matched) => statSync(matched).isFile(),
           );
+
           for (const path of files) {
             this.actionOnFile({ ...option, path, action: 'change' });
           }

From 68508b25308dff02f82300669b5c9b374783a8ae Mon Sep 17 00:00:00 2001
From: Flavio Moreno <flavio.moreno941@gmail.com>
Date: Sun, 24 Mar 2024 18:45:11 +0100
Subject: [PATCH 2/2] fix(assets): Refactor

Refactoring few mistakes
---
 lib/compiler/assets-manager.ts | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/compiler/assets-manager.ts b/lib/compiler/assets-manager.ts
index 6ef92c708..2d471d59b 100644
--- a/lib/compiler/assets-manager.ts
+++ b/lib/compiler/assets-manager.ts
@@ -1,4 +1,4 @@
-import * as   chokidar from 'chokidar';
+import * as chokidar from 'chokidar';
 import { statSync } from 'fs';
 import { sync } from 'glob';
 import { dirname, join, sep } from 'path';
@@ -104,7 +104,6 @@ export class AssetsManager {
           const files = sync(item.glob, { ignore: item.exclude }).filter(
             (matched) => statSync(matched).isFile(),
           );
-
           for (const path of files) {
             this.actionOnFile({ ...option, path, action: 'change' });
           }