Skip to content

Commit 9cbe046

Browse files
committed
fix file normalization errors for Windows
- for "globby", candidate glob expressions must always be normalized to forward slashes - see <sindresorhus/globby#130> - see <https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows> @@ <https://archive.is/YUnk2#70.8%>
1 parent d34976c commit 9cbe046

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

api.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
'use strict';
2+
const isWinOS = /^win/i.test(process.platform);
3+
24
const {promisify} = require('util');
35
const path = require('path');
46
const fs = require('fs');
7+
const normalizePath = isWinOS ? require('normalize-path') : s => s;
58
const writeFileAtomic = require('write-file-atomic');
69
const escapeStringRegexp = require('escape-string-regexp');
710
const arrify = require('arrify');
@@ -33,7 +36,7 @@ module.exports = async (filePaths, {find, replacement, ignoreCase, glob} = {}) =
3336
.replace(/\\r/g, '\r')
3437
.replace(/\\t/g, '\t');
3538

36-
filePaths = glob ? await globby(filePaths) : [...new Set(filePaths.map(filePath => path.resolve(filePath)))];
39+
filePaths = glob ? await globby(filePaths.map(filePath => normalizePath(filePath))) : [...new Set(filePaths.map(filePath => normalizePath(path.resolve(filePath))))];
3740

3841
find = find.map(element => {
3942
const iFlag = ignoreCase ? 'i' : '';

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"escape-string-regexp": "^2.0.0",
4646
"globby": "^10.0.1",
4747
"meow": "^5.0.0",
48+
"normalize-path": "^3.0.0",
4849
"write-file-atomic": "^3.0.0"
4950
},
5051
"devDependencies": {

0 commit comments

Comments
 (0)