@11ty/recursive-copy
Advanced tools
| var minimatch = require("minimatch"); | ||
| // via https://github.com/sindresorhus/array-union (MIT license) | ||
| function arrayUnion(...args) { | ||
| return [...new Set(args.flat())]; | ||
| } | ||
| // via https://github.com/sindresorhus/array-differ/blob/main/index.js (MIT license) | ||
| function arrayDiffer(array, ...values) { | ||
| const rest = new Set(values.flat()); | ||
| return array.filter(element => !rest.has(element)); | ||
| } | ||
| // via https://github.com/sindresorhus/arrify/blob/main/index.js (MIT license) | ||
| function arrify(value) { | ||
| if (value === null || value === undefined) { | ||
| return []; | ||
| } | ||
| if (Array.isArray(value)) { | ||
| return value; | ||
| } | ||
| if (typeof value === 'string') { | ||
| return [value]; | ||
| } | ||
| if (typeof value[Symbol.iterator] === 'function') { | ||
| return [...value]; | ||
| } | ||
| return [value]; | ||
| } | ||
| // via https://www.npmjs.com/package/maximatch (MIT license) | ||
| module.exports = function (list, patterns, options) { | ||
| list = arrify(list); | ||
| patterns = arrify(patterns); | ||
| if (list.length === 0 || patterns.length === 0) { | ||
| return []; | ||
| } | ||
| options = options || {}; | ||
| return patterns.reduce(function (ret, pattern) { | ||
| if (typeof pattern === "function") { | ||
| return arrayUnion(ret, list.filter(pattern)); | ||
| } else if (pattern instanceof RegExp) { | ||
| return arrayUnion( | ||
| ret, | ||
| list.filter(function (item) { | ||
| return pattern.test(item); | ||
| }), | ||
| ); | ||
| } else { | ||
| var process = arrayUnion; | ||
| if (pattern[0] === "!") { | ||
| pattern = pattern.slice(1); | ||
| process = arrayDiffer; | ||
| } | ||
| return process(ret, minimatch.match(list, pattern, options)); | ||
| } | ||
| }, []); | ||
| }; |
+10
| // via https://github.com/sindresorhus/slash/blob/main/index.js (MIT license) | ||
| module.exports = function slash(path) { | ||
| const isExtendedLengthPath = path.startsWith('\\\\?\\'); | ||
| if (isExtendedLengthPath) { | ||
| return path; | ||
| } | ||
| return path.replace(/\\/g, '/'); | ||
| } |
+2
-2
@@ -9,4 +9,4 @@ 'use strict'; | ||
| var errno = require('errno'); | ||
| var maximatch = require('maximatch'); | ||
| var slash = require('slash'); | ||
| var slash = require('./slash.js'); | ||
| var maximatch = require('./maximatch.js'); | ||
@@ -13,0 +13,0 @@ var CopyError = errno.custom.createError('CopyError'); |
+2
-3
| { | ||
| "name": "@11ty/recursive-copy", | ||
| "version": "4.0.3", | ||
| "version": "5.0.0", | ||
| "description": "A fork of `recursive-copy`: Simple, flexible file copy utility", | ||
@@ -57,4 +57,3 @@ "engines": { | ||
| "junk": "^3.1.0", | ||
| "maximatch": "^0.1.0", | ||
| "slash": "^3.0.0" | ||
| "minimatch": "^10.1.1" | ||
| }, | ||
@@ -61,0 +60,0 @@ "devDependencies": { |
26380
7.25%3
-25%7
40%574
12.11%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed