Skip to content

Commit eaf4306

Browse files
authoredMar 22, 2019
fix: watch on windows (#359)
1 parent a8fc34e commit eaf4306

5 files changed

+189
-200
lines changed
 

‎README.md

+127-41
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,34 @@ module.exports = {
5858

5959
### Patterns
6060

61-
| Name | Type | Default | Description |
62-
| :-------------------------------: | :-------------------: | :---------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
63-
| [`from`](#from) | `{String\|Object}` | `undefined` | Globs accept [minimatch options](https://github.com/isaacs/minimatch). See the [`node-glob` options](https://github.com/isaacs/node-glob#options) in addition to the ones below. |
64-
| [`to`](#to) | `{String\|Object}` | `undefined` | Output root if `from` is file or dir, resolved glob path if `from` is glob. |
65-
| [`toType`](#toType) | `{String}` | `undefined` | `[toType Options](#totype)`. |
66-
| [`test`](#test) | `{RegExp}` | `undefined` | Pattern for extracting elements to be used in `to` templates. |
67-
| [`force`](#force) | `{Boolean}` | `false` | Overwrites files already in `compilation.assets` (usually added by other plugins/loaders). |
68-
| [`ignore`](#ignore) | `{Array}` | `[]` | Globs to ignore for this pattern. |
69-
| [`flatten`](#flatten) | `{Boolean}` | `false` | Removes all directory references and only copies file names.⚠️ If files have the same name, the result is non-deterministic. |
70-
| [`transform`](#transform) | `{Function\|Promise}` | `(content, path) => content` | Function or Promise that modifies file contents before copying. |
71-
| [`transformPath`](#transformPath) | `{Function\|Promise}` | `(targetPath, sourcePath) => path` | Function or Promise that modifies file writing path. |
72-
| [`cache`](#cache) | `{Boolean\|Object}` | `false` | Enable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache. |
73-
| [`context`](#context) | `{String}` | `options.context \|\| compiler.options.context` | A path that determines how to interpret the `from` path. |
61+
| Name | Type | Default | Description |
62+
| :-------------------------------: | :-------------------: | :---------------------------------------------: | :---------------------------------------------------------------------------------------------------- |
63+
| [`from`](#from) | `{String\|Object}` | `undefined` | Glob or path from where we сopy files. |
64+
| [`to`](#to) | `{String}` | `undefined` | Output path. |
65+
| [`context`](#context) | `{String}` | `options.context \|\| compiler.options.context` | A path that determines how to interpret the `from` path. |
66+
| [`toType`](#toType) | `{String}` | `undefined` | Determinate what is `to` option - directory, file or template. |
67+
| [`test`](#test) | `{RegExp}` | `undefined` | Pattern for extracting elements to be used in `to` templates. |
68+
| [`force`](#force) | `{Boolean}` | `false` | Overwrites files already in `compilation.assets` (usually added by other plugins/loaders). |
69+
| [`ignore`](#ignore) | `{Array}` | `[]` | Globs to ignore files. |
70+
| [`flatten`](#flatten) | `{Boolean}` | `false` | Removes all directory references and only copies file names. |
71+
| [`transform`](#transform) | `{Function\|Promise}` | `undefined` | Allows to modify the file contents. |
72+
| [`cache`](#cache) | `{Boolean\|Object}` | `false` | Enable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache. |
73+
| [`transformPath`](#transformPath) | `{Function\|Promise}` | `undefined` | Allows to modify the writing path. |
7474

7575
#### `from`
7676

77+
Type: `String\|Object`
78+
Default: `undefined`
79+
80+
Glob or path from where we сopy files.
81+
Globs accept [minimatch options](https://github.com/isaacs/minimatch).
82+
83+
You can defined `from` as `Object` and use the [`node-glob` options](https://github.com/isaacs/node-glob#options).
84+
85+
> ⚠️ Don't use directly `\\` in `from` (i.e `path\to\file.ext`) option because on UNIX the backslash is a valid character inside a path component, i.e., it's not a separator.
86+
> On Windows, the forward slash and the backward slash are both separators.
87+
> Instead please use `/` or `path` methods.
88+
7789
**webpack.config.js**
7890

7991
```js
@@ -93,6 +105,15 @@ module.exports = {
93105

94106
#### `to`
95107

108+
Type: `String`
109+
Default: `undefined`
110+
111+
Output path.
112+
113+
> ⚠️ Don't use directly `\\` in `to` (i.e `path\to\dest`) option because on UNIX the backslash is a valid character inside a path component, i.e., it's not a separator.
114+
> On Windows, the forward slash and the backward slash are both separators.
115+
> Instead please use `/` or `path` methods.
116+
96117
**webpack.config.js**
97118

98119
```js
@@ -106,8 +127,43 @@ module.exports = {
106127
};
107128
```
108129

130+
#### `context`
131+
132+
Type: `String`
133+
Default: `options.context|compiler.options.context`
134+
135+
A path that determines how to interpret the `from` path.
136+
137+
> ⚠️ Don't use directly `\\` in `context` (i.e `path\to\context`) option because on UNIX the backslash is a valid character inside a path component, i.e., it's not a separator.
138+
> On Windows, the forward slash and the backward slash are both separators.
139+
> Instead please use `/` or `path` methods.
140+
141+
**webpack.config.js**
142+
143+
```js
144+
module.exports = {
145+
plugins: [
146+
new CopyPlugin([
147+
{
148+
from: 'src/*.txt',
149+
to: 'dest/',
150+
context: 'app/',
151+
},
152+
]),
153+
],
154+
};
155+
```
156+
109157
#### `toType`
110158

159+
Type: `String`
160+
Default: `undefined`
161+
162+
Determinate what is `to` option - directory, file or template.
163+
Sometimes it is hard to say what is `to`, example `path/to/dir-with.ext`.
164+
If you want to copy files in directory you need use `dir` option.
165+
We try to automatically determine the `type` so you most likely do not need this option.
166+
111167
| Name | Type | Default | Description |
112168
| :--------------: | :--------: | :---------: | :------------------------------------------------------------------------------------------------- |
113169
| **`'dir'`** | `{String}` | `undefined` | If `from` is directory, `to` has no extension or ends in `'/'` |
@@ -170,6 +226,11 @@ module.exports = {
170226

171227
#### `test`
172228

229+
Type: `RegExp`
230+
Default: `undefined`
231+
232+
Pattern for extracting elements to be used in `to` templates.
233+
173234
Defines a `{RegExp}` to match some parts of the file path.
174235
These capture groups can be reused in the name property using `[N]` placeholder.
175236
Note that `[0]` will be replaced by the entire path of the file,
@@ -194,6 +255,11 @@ module.exports = {
194255

195256
#### `force`
196257

258+
Type: `Boolean`
259+
Default: `false`
260+
261+
Overwrites files already in `compilation.assets` (usually added by other plugins/loaders).
262+
197263
**webpack.config.js**
198264

199265
```js
@@ -212,6 +278,11 @@ module.exports = {
212278

213279
#### `ignore`
214280

281+
Type: `Array`
282+
Default: `[]`
283+
284+
Globs to ignore files.
285+
215286
**webpack.config.js**
216287

217288
```js
@@ -230,6 +301,13 @@ module.exports = {
230301

231302
#### `flatten`
232303

304+
Type: `Boolean`
305+
Default: `false`
306+
307+
Removes all directory references and only copies file names.
308+
309+
> ⚠️ If files have the same name, the result is non-deterministic.
310+
233311
**webpack.config.js**
234312

235313
```js
@@ -248,6 +326,11 @@ module.exports = {
248326

249327
#### `transform`
250328

329+
Type: `Function|Promise`
330+
Default: `undefined`
331+
332+
Allows to modify the file contents.
333+
251334
##### `{Function}`
252335

253336
**webpack.config.js**
@@ -288,9 +371,13 @@ module.exports = {
288371
};
289372
```
290373

291-
#### `transformPath`
374+
#### `cache`
292375

293-
##### `{Function}`
376+
Type: `Boolean|Object`
377+
Default: `false`
378+
379+
Enable/disable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache.
380+
Default path to cache directory: `node_modules/.cache/copy-webpack-plugin`.
294381

295382
**webpack.config.js**
296383

@@ -301,36 +388,28 @@ module.exports = {
301388
{
302389
from: 'src/*.png',
303390
to: 'dest/',
304-
transformPath(targetPath, absolutePath) {
305-
return 'newPath';
391+
transform(content, path) {
392+
return optimize(content);
306393
},
394+
cache: true,
307395
},
308396
]),
309397
],
310398
};
311399
```
312400

313-
##### `{Promise}`
401+
#### `transformPath`
314402

315-
**webpack.config.js**
403+
Type: `Function|Promise`
404+
Default: `undefined`
316405

317-
```js
318-
module.exports = {
319-
plugins: [
320-
new CopyPlugin([
321-
{
322-
from: 'src/*.png',
323-
to: 'dest/',
324-
transformPath(targePath, absolutePath) {
325-
return Promise.resolve('newPath');
326-
},
327-
},
328-
]),
329-
],
330-
};
331-
```
406+
Allows to modify the writing path.
332407

333-
#### `cache`
408+
> ⚠️ Don't return directly `\\` in `transformPath` (i.e `path\to\newFile`) option because on UNIX the backslash is a valid character inside a path component, i.e., it's not a separator.
409+
> On Windows, the forward slash and the backward slash are both separators.
410+
> Instead please use `/` or `path` methods.
411+
412+
##### `{Function}`
334413

335414
**webpack.config.js**
336415

@@ -341,17 +420,16 @@ module.exports = {
341420
{
342421
from: 'src/*.png',
343422
to: 'dest/',
344-
transform(content, path) {
345-
return optimize(content);
423+
transformPath(targetPath, absolutePath) {
424+
return 'newPath';
346425
},
347-
cache: true,
348426
},
349427
]),
350428
],
351429
};
352430
```
353431

354-
#### `context`
432+
##### `{Promise}`
355433

356434
**webpack.config.js**
357435

@@ -360,9 +438,11 @@ module.exports = {
360438
plugins: [
361439
new CopyPlugin([
362440
{
363-
from: 'src/*.txt',
441+
from: 'src/*.png',
364442
to: 'dest/',
365-
context: 'app/',
443+
transformPath(targePath, absolutePath) {
444+
return Promise.resolve('newPath');
445+
},
366446
},
367447
]),
368448
],
@@ -404,6 +484,8 @@ module.exports = {
404484

405485
#### `ignore`
406486

487+
Array of globs to ignore (applied to `from`).
488+
407489
**webpack.config.js**
408490

409491
```js
@@ -414,6 +496,8 @@ module.exports = {
414496

415497
#### `context`
416498

499+
A path that determines how to interpret the `from` path, shared for all patterns.
500+
417501
**webpack.config.js**
418502

419503
```js
@@ -424,6 +508,8 @@ module.exports = {
424508

425509
#### `copyUnmodified`
426510

511+
Copies files, regardless of modification when using watch or `webpack-dev-server`. All files are copied on first build, regardless of this option.
512+
427513
> ℹ️ By default, we only copy **modified** files during a `webpack --watch` or `webpack-dev-server` build. Setting this option to `true` will copy all files.
428514
429515
**webpack.config.js**

‎src/postProcessPattern.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import loaderUtils from 'loader-utils';
66
import cacache from 'cacache';
77
import serialize from 'serialize-javascript';
88
import findCacheDir from 'find-cache-dir';
9-
import normalizePath from 'normalize-path';
109

1110
import { name, version } from '../package.json';
1211

@@ -114,18 +113,18 @@ export default function postProcessPattern(globalRef, pattern, file) {
114113
file.webpackTo = file.webpackTo.replace(/\.?\[ext\]/g, '');
115114
}
116115

117-
// Developers can use invalid slashes in regex we should fix it
118-
file.webpackTo = normalizePath(
119-
loaderUtils.interpolateName(
120-
{ resourcePath: file.absoluteFrom },
121-
file.webpackTo,
122-
{
123-
content,
124-
regExp: file.webpackToRegExp,
125-
context: pattern.context,
126-
}
127-
)
116+
file.webpackTo = loaderUtils.interpolateName(
117+
{ resourcePath: file.absoluteFrom },
118+
file.webpackTo,
119+
{
120+
content,
121+
regExp: file.webpackToRegExp,
122+
context: pattern.context,
123+
}
128124
);
125+
126+
// Bug in `loader-utils`, package convert `\\` to `/`, need fix in loader-utils
127+
file.webpackTo = path.normalize(file.webpackTo);
129128
}
130129

131130
return content;
@@ -141,7 +140,7 @@ export default function postProcessPattern(globalRef, pattern, file) {
141140
)
142141
.then((newPath) => {
143142
// Developers can use invalid slashes we should fix it
144-
file.webpackTo = normalizePath(newPath);
143+
file.webpackTo = path.normalize(newPath);
145144
})
146145
.then(() => content);
147146
}

‎src/preProcessPattern.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import path from 'path';
22

33
import isGlob from 'is-glob';
44
import globParent from 'glob-parent';
5-
import normalizePath from 'normalize-path';
65

76
import normalize from './utils/normalize';
87
import isObject from './utils/isObject';
@@ -45,7 +44,16 @@ export default function preProcessPattern(globalRef, pattern) {
4544
pattern.context = path.join(context, pattern.context);
4645
}
4746

48-
pattern.context = normalizePath(pattern.context);
47+
const isFromGlobPatten = isObject(pattern.from) && pattern.from.glob;
48+
// Todo remove this in next major
49+
const isToDirectory =
50+
path.extname(pattern.to) === '' || pattern.to.slice(-1) === path.sep;
51+
52+
// Normalize paths
53+
pattern.from = isFromGlobPatten ? pattern.from : path.normalize(pattern.from);
54+
pattern.context = path.normalize(pattern.context);
55+
pattern.to = path.normalize(pattern.to);
56+
4957
pattern.ignore = globalRef.ignore.concat(pattern.ignore || []);
5058

5159
logger.debug(`processing from: '${pattern.from}' to: '${pattern.to}'`);
@@ -57,15 +65,15 @@ export default function preProcessPattern(globalRef, pattern) {
5765
case isTemplateLike.test(pattern.to):
5866
pattern.toType = 'template';
5967
break;
60-
case path.extname(pattern.to) === '' || pattern.to.slice(-1) === '/':
68+
case isToDirectory:
6169
pattern.toType = 'dir';
6270
break;
6371
default:
6472
pattern.toType = 'file';
6573
}
6674

6775
// If we know it's a glob, then bail early
68-
if (isObject(pattern.from) && pattern.from.glob) {
76+
if (isFromGlobPatten) {
6977
logger.debug(`determined '${pattern.absoluteFrom}' is a glob`);
7078

7179
pattern.fromType = 'glob';
@@ -75,9 +83,7 @@ export default function preProcessPattern(globalRef, pattern) {
7583

7684
pattern.glob = normalize(pattern.context, pattern.from.glob);
7785
pattern.globOptions = globOptions;
78-
pattern.absoluteFrom = normalizePath(
79-
path.resolve(pattern.context, pattern.from.glob)
80-
);
86+
pattern.absoluteFrom = path.resolve(pattern.context, pattern.from.glob);
8187

8288
return Promise.resolve(pattern);
8389
}
@@ -88,9 +94,6 @@ export default function preProcessPattern(globalRef, pattern) {
8894
pattern.absoluteFrom = path.resolve(pattern.context, pattern.from);
8995
}
9096

91-
// Normalize path when path separators are mixed (like `C:\\directory/nested-directory/`)
92-
pattern.absoluteFrom = normalizePath(pattern.absoluteFrom);
93-
9497
logger.debug(
9598
`determined '${pattern.from}' to be read from '${pattern.absoluteFrom}'`
9699
);
@@ -105,7 +108,8 @@ export default function preProcessPattern(globalRef, pattern) {
105108

106109
// We need to add context directory as dependencies to avoid problems when new files added in directories
107110
// when we already in watch mode and this directories are not in context dependencies
108-
contextDependencies.add(globParent(pattern.absoluteFrom));
111+
// `glob-parent` always return `/` we need normalize path
112+
contextDependencies.add(path.normalize(globParent(pattern.absoluteFrom)));
109113
} else {
110114
const newWarning = new Error(
111115
`unable to locate '${pattern.from}' at '${pattern.absoluteFrom}'`
@@ -147,9 +151,7 @@ export default function preProcessPattern(globalRef, pattern) {
147151
pattern.fromType = 'dir';
148152
pattern.context = pattern.absoluteFrom;
149153
pattern.glob = normalize(pattern.absoluteFrom, '**/*');
150-
pattern.absoluteFrom = normalizePath(
151-
path.join(pattern.absoluteFrom, '**/*')
152-
);
154+
pattern.absoluteFrom = path.join(pattern.absoluteFrom, '**/*');
153155
pattern.globOptions = {
154156
dot: true,
155157
};
@@ -159,7 +161,7 @@ export default function preProcessPattern(globalRef, pattern) {
159161
fileDependencies.add(pattern.absoluteFrom);
160162

161163
pattern.fromType = 'file';
162-
pattern.context = normalizePath(path.dirname(pattern.absoluteFrom));
164+
pattern.context = path.dirname(pattern.absoluteFrom);
163165
pattern.glob = normalize(pattern.absoluteFrom);
164166
pattern.globOptions = {
165167
dot: true,

‎src/processPattern.js

-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import path from 'path';
33
import globby from 'globby';
44
import pLimit from 'p-limit';
55
import minimatch from 'minimatch';
6-
import normalizePath from 'normalize-path';
76

87
import isObject from './utils/isObject';
98

@@ -42,9 +41,6 @@ export default function processPattern(globalRef, pattern) {
4241
file.relativeFrom = path.basename(file.relativeFrom);
4342
}
4443

45-
// Ensure forward slashes
46-
file.relativeFrom = normalizePath(file.relativeFrom);
47-
4844
logger.debug(`found ${from}`);
4945

5046
// Check the ignore list
@@ -113,9 +109,6 @@ export default function processPattern(globalRef, pattern) {
113109
file.webpackTo = path.relative(output, file.webpackTo);
114110
}
115111

116-
// Ensure forward slashes
117-
file.webpackTo = normalizePath(file.webpackTo);
118-
119112
logger.info(
120113
`determined that '${from}' should write to '${file.webpackTo}'`
121114
);

‎test/CopyPlugin.test.js

+33-124
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import findCacheDir from 'find-cache-dir';
1010
import cacache from 'cacache';
1111
import isGzip from 'is-gzip';
1212
import mkdirp from 'mkdirp';
13-
import normalizePath from 'normalize-path';
1413

1514
import CopyPlugin from '../src/index';
1615

@@ -160,7 +159,10 @@ describe('apply function', () => {
160159
run(opts).then((compilation) => {
161160
if (opts.expectedAssetKeys && opts.expectedAssetKeys.length > 0) {
162161
expect(Object.keys(compilation.assets).sort()).toEqual(
163-
opts.expectedAssetKeys.sort().map(removeIllegalCharacterForWindows)
162+
opts.expectedAssetKeys
163+
.sort()
164+
.map(removeIllegalCharacterForWindows)
165+
.map((item) => item.replace(/\//g, path.sep))
164166
);
165167
} else {
166168
expect(compilation.assets).toEqual({});
@@ -169,16 +171,18 @@ describe('apply function', () => {
169171
if (opts.expectedAssetContent) {
170172
// eslint-disable-next-line guard-for-in
171173
for (const key in opts.expectedAssetContent) {
172-
expect(compilation.assets[key]).toBeDefined();
174+
const assetName = key.replace(/(\/|\\)/g, path.sep);
173175

174-
if (compilation.assets[key]) {
176+
expect(compilation.assets[assetName]).toBeDefined();
177+
178+
if (compilation.assets[assetName]) {
175179
let expectedContent = opts.expectedAssetContent[key];
176180

177181
if (!Buffer.isBuffer(expectedContent)) {
178182
expectedContent = Buffer.from(expectedContent);
179183
}
180184

181-
let compiledContent = compilation.assets[key].source();
185+
let compiledContent = compilation.assets[assetName].source();
182186

183187
if (!Buffer.isBuffer(compiledContent)) {
184188
compiledContent = Buffer.from(compiledContent);
@@ -237,13 +241,17 @@ describe('apply function', () => {
237241
.then(() => {
238242
if (opts.expectedAssetKeys && opts.expectedAssetKeys.length > 0) {
239243
expect(Object.keys(compilation.assets).sort()).toEqual(
240-
opts.expectedAssetKeys.sort()
244+
opts.expectedAssetKeys
245+
.sort()
246+
.map(removeIllegalCharacterForWindows)
247+
.map((item) => item.replace(/\//g, path.sep))
241248
);
242249
} else {
243250
expect(compilation.assets).toEqual({});
244251
}
245252
})
246253
.then(() => {
254+
// Todo finally and check file exists
247255
fs.unlinkSync(opts.newFileLoc1);
248256
fs.unlinkSync(opts.newFileLoc2);
249257
});
@@ -485,7 +493,10 @@ describe('apply function', () => {
485493
transformPath(targetPath, absoluteFrom) {
486494
expect(absoluteFrom.includes(HELPER_DIR)).toBe(true);
487495

488-
return targetPath.replace('nested/', 'transformed/');
496+
return targetPath.replace(
497+
`nested${path.sep}`,
498+
`transformed${path.sep}`
499+
);
489500
},
490501
},
491502
],
@@ -687,9 +698,9 @@ describe('apply function', () => {
687698
.then((compilation) => {
688699
expect(
689700
Array.from(compilation.contextDependencies)
690-
.map((contextDependency) => normalizePath(contextDependency))
701+
.map((contextDependency) => contextDependency)
691702
.sort()
692-
).toEqual([normalizePath(path.join(HELPER_DIR, 'directory'))].sort());
703+
).toEqual([path.join(HELPER_DIR, 'directory')].sort());
693704
})
694705
.then(done)
695706
.catch(done);
@@ -797,9 +808,9 @@ describe('apply function', () => {
797808
expectedAssetKeys: [],
798809
expectedWarnings: [
799810
new Error(
800-
`unable to locate 'nonexistent.txt' at '${normalizePath(
801-
HELPER_DIR
802-
)}/nonexistent.txt'`
811+
`unable to locate 'nonexistent.txt' at '${HELPER_DIR}${
812+
path.sep
813+
}nonexistent.txt'`
803814
),
804815
],
805816
patterns: [
@@ -818,9 +829,9 @@ describe('apply function', () => {
818829
expectedAssetKeys: [],
819830
expectedWarnings: [
820831
new Error(
821-
`unable to locate 'nonexistent.txt' at '${normalizePath(
822-
HELPER_DIR
823-
)}/nonexistent.txt'`
832+
`unable to locate 'nonexistent.txt' at '${HELPER_DIR}${
833+
path.sep
834+
}nonexistent.txt'`
824835
),
825836
],
826837
patterns: [
@@ -1057,13 +1068,13 @@ describe('apply function', () => {
10571068
.catch(done);
10581069
});
10591070

1060-
it('can move a file to a new directory with an extension and forward slash', (done) => {
1071+
it('can move a file to a new directory with an extension and path separator at end', (done) => {
10611072
runEmit({
10621073
expectedAssetKeys: ['newdirectory.ext/file.txt'],
10631074
patterns: [
10641075
{
10651076
from: 'file.txt',
1066-
to: 'newdirectory.ext/',
1077+
to: `newdirectory.ext${path.sep}`,
10671078
},
10681079
],
10691080
})
@@ -1236,7 +1247,7 @@ describe('apply function', () => {
12361247
],
12371248
})
12381249
.then((compilation) => {
1239-
const absFrom = normalizePath(path.join(HELPER_DIR, 'file.txt'));
1250+
const absFrom = path.join(HELPER_DIR, 'file.txt');
12401251

12411252
expect(Array.from(compilation.fileDependencies).sort()).toEqual(
12421253
[absFrom].sort()
@@ -1478,9 +1489,9 @@ describe('apply function', () => {
14781489
expectedAssetKeys: [],
14791490
expectedWarnings: [
14801491
new Error(
1481-
`unable to locate 'nonexistent' at '${normalizePath(
1482-
HELPER_DIR
1483-
)}/nonexistent'`
1492+
`unable to locate 'nonexistent' at '${HELPER_DIR}${
1493+
path.sep
1494+
}nonexistent'`
14841495
),
14851496
],
14861497
patterns: [
@@ -1680,7 +1691,7 @@ describe('apply function', () => {
16801691
],
16811692
})
16821693
.then((compilation) => {
1683-
const absFrom = normalizePath(path.resolve(HELPER_DIR, 'directory'));
1694+
const absFrom = path.resolve(HELPER_DIR, 'directory');
16841695
expect(Array.from(compilation.contextDependencies).sort()).toEqual(
16851696
[absFrom].sort()
16861697
);
@@ -1822,71 +1833,6 @@ describe('apply function', () => {
18221833
.catch(done);
18231834
});
18241835

1825-
it('can normalize mixed path segment separation with glob in from (simple)', (done) => {
1826-
runEmit({
1827-
expectedAssetKeys: ['directory/nested/nestedfile.txt'],
1828-
patterns: [
1829-
{
1830-
from: 'directory/nested\\*',
1831-
},
1832-
],
1833-
})
1834-
.then(done)
1835-
.catch(done);
1836-
});
1837-
1838-
it('can normalize backslash path with file in from', (done) => {
1839-
runEmit({
1840-
expectedAssetKeys: ['nestedfile.txt'],
1841-
patterns: [
1842-
{
1843-
from: 'directory\\nested\\nestedfile.txt',
1844-
},
1845-
],
1846-
})
1847-
.then(done)
1848-
.catch(done);
1849-
});
1850-
1851-
it('can normalize backslash path with file in from (mixed path segment separation)', (done) => {
1852-
runEmit({
1853-
expectedAssetKeys: ['nestedfile.txt'],
1854-
patterns: [
1855-
{
1856-
from: 'directory\\nested/nestedfile.txt',
1857-
},
1858-
],
1859-
})
1860-
.then(done)
1861-
.catch(done);
1862-
});
1863-
1864-
it('can normalize backslash path with directory in from', (done) => {
1865-
runEmit({
1866-
expectedAssetKeys: ['deepnested.txt'],
1867-
patterns: [
1868-
{
1869-
from: 'directory\\nested\\deep-nested',
1870-
},
1871-
],
1872-
})
1873-
.then(done)
1874-
.catch(done);
1875-
});
1876-
1877-
it('can normalize backslash path with directory in from (mixed path segment separation)', (done) => {
1878-
runEmit({
1879-
expectedAssetKeys: ['deepnested.txt'],
1880-
patterns: [
1881-
{
1882-
from: 'directory\\nested\\deep-nested',
1883-
},
1884-
],
1885-
})
1886-
.then(done)
1887-
.catch(done);
1888-
});
1889-
18901836
it('can exclude path', (done) => {
18911837
runEmit({
18921838
expectedAssetKeys: [
@@ -1928,43 +1874,6 @@ describe('apply function', () => {
19281874
.then(done)
19291875
.catch(done);
19301876
});
1931-
1932-
it('can normalize backslash in context', (done) => {
1933-
runEmit({
1934-
expectedAssetKeys: [
1935-
'newdirectory/deep-nested/deepnested.txt',
1936-
'newdirectory/nestedfile.txt',
1937-
],
1938-
options: {
1939-
context: path.resolve(HELPER_DIR, 'directory\\'),
1940-
},
1941-
patterns: [
1942-
{
1943-
from: 'nested',
1944-
to: 'newdirectory',
1945-
},
1946-
],
1947-
})
1948-
.then(done)
1949-
.catch(done);
1950-
});
1951-
1952-
it('can normalize backslash in context (2)', (done) => {
1953-
runEmit({
1954-
expectedAssetKeys: ['newdirectory/deepnested.txt'],
1955-
options: {
1956-
context: path.resolve(HELPER_DIR, 'directory\\nested'),
1957-
},
1958-
patterns: [
1959-
{
1960-
from: 'deep-nested',
1961-
to: 'newdirectory',
1962-
},
1963-
],
1964-
})
1965-
.then(done)
1966-
.catch(done);
1967-
});
19681877
});
19691878

19701879
describe('modified files', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.