Skip to content

Commit

Permalink
fix file normalization errors for Windows
Browse files Browse the repository at this point in the history
- 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%>
  • Loading branch information
rivy committed Oct 6, 2019
1 parent 96f512f commit ec8a9ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict';
const isWinOS = /^win/i.test(process.platform);

const {promisify} = require('util');
const path = require('path');
const fs = require('fs');
const normalizePath = isWinOS ? require('normalize-path') : s => s;
const writeFileAtomic = require('write-file-atomic');
const escapeStringRegexp = require('escape-string-regexp');
const arrify = require('arrify');
Expand Down Expand Up @@ -33,7 +36,7 @@ module.exports = async (filePaths, {find, replacement, ignoreCase, glob} = {}) =
.replace(/\\r/g, '\r')
.replace(/\\t/g, '\t');

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

find = find.map(element => {
const iFlag = ignoreCase ? 'i' : '';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"escape-string-regexp": "^2.0.0",
"globby": "^10.0.1",
"meow": "^5.0.0",
"normalize-path": "^3.0.0",
"write-file-atomic": "^3.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit ec8a9ed

Please sign in to comment.