|
1 | | -import * as chokidar from 'chokidar'; |
| 1 | +import * as chokidar from 'chokidar'; |
2 | 2 | import { statSync } from 'fs'; |
3 | 3 | import { sync } from 'glob'; |
4 | 4 | import { dirname, join, sep } from 'path'; |
@@ -60,18 +60,18 @@ export class AssetsManager { |
60 | 60 | sourceRoot = join(process.cwd(), sourceRoot); |
61 | 61 |
|
62 | 62 | 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 | + |
69 | 69 | 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, |
75 | 75 | }; |
76 | 76 | }); |
77 | 77 |
|
@@ -104,6 +104,7 @@ export class AssetsManager { |
104 | 104 | const files = sync(item.glob, { ignore: item.exclude }).filter( |
105 | 105 | (matched) => statSync(matched).isFile(), |
106 | 106 | ); |
| 107 | + |
107 | 108 | for (const path of files) { |
108 | 109 | this.actionOnFile({ ...option, path, action: 'change' }); |
109 | 110 | } |
|
0 commit comments