Comparing version 1.0.3 to 1.0.4
@@ -6,20 +6,15 @@ "use strict"; | ||
}); | ||
exports.correctPath = correctPath; | ||
exports.unixify = unixify; | ||
exports.correctPath = correctPath; | ||
var isWin = process.platform === 'win32'; | ||
function removeTrailingSeparator(str) { | ||
var i = str.length - 1; | ||
if (i < 2) { | ||
return str; | ||
} | ||
while (isSeparator(str, i)) { | ||
i--; | ||
} | ||
return str.substr(0, i + 1); | ||
} | ||
function isSeparator(str, i) { | ||
@@ -29,3 +24,2 @@ var _char = str[i]; | ||
} | ||
function normalizePath(str, stripTrailing) { | ||
@@ -35,15 +29,10 @@ if (typeof str !== 'string') { | ||
} | ||
str = str.replace(/[\\\/]+/g, '/'); | ||
if (stripTrailing !== false) { | ||
str = removeTrailingSeparator(str); | ||
} | ||
return str; | ||
} | ||
function unixify(filepath) { | ||
var stripTrailing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
if (isWin) { | ||
@@ -53,8 +42,6 @@ filepath = normalizePath(filepath, stripTrailing); | ||
} | ||
return filepath; | ||
} | ||
function correctPath(filepath) { | ||
return unixify(filepath.replace(/^\\\\\?\\.:\\/, '\\')); | ||
} |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -27,17 +26,9 @@ value: true | ||
exports.util = void 0; | ||
var _patchFs = _interopRequireDefault(require("./patchFs")); | ||
var _patchRequire = _interopRequireDefault(require("./patchRequire")); | ||
var _correctPath = require("./correctPath"); | ||
var util = _interopRequireWildcard(require("./util/lists")); | ||
exports.util = util; | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } |
@@ -7,15 +7,9 @@ "use strict"; | ||
exports["default"] = patchFs; | ||
var _lists = require("./util/lists"); | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function patchFs(vol) { | ||
var fs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : require('fs'); | ||
var bkp = {}; | ||
var patch = function patch(key, newValue) { | ||
@@ -25,10 +19,7 @@ bkp[key] = fs[key]; | ||
}; | ||
var patchMethod = function patchMethod(key) { | ||
return patch(key, vol[key].bind(vol)); | ||
}; | ||
var _iterator = _createForOfIteratorHelper(_lists.fsProps), | ||
_step; | ||
_step; | ||
try { | ||
@@ -44,24 +35,17 @@ for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
} | ||
if (typeof vol.StatWatcher === 'function') { | ||
patch('StatWatcher', vol.FSWatcher.bind(null, vol)); | ||
} | ||
if (typeof vol.FSWatcher === 'function') { | ||
patch('FSWatcher', vol.StatWatcher.bind(null, vol)); | ||
} | ||
if (typeof vol.ReadStream === 'function') { | ||
patch('ReadStream', vol.ReadStream.bind(null, vol)); | ||
} | ||
if (typeof vol.WriteStream === 'function') { | ||
patch('WriteStream', vol.WriteStream.bind(null, vol)); | ||
} | ||
if (typeof vol._toUnixTimestamp === 'function') patchMethod('_toUnixTimestamp'); | ||
var _iterator2 = _createForOfIteratorHelper(_lists.fsAsyncMethods), | ||
_step2; | ||
_step2; | ||
try { | ||
@@ -77,6 +61,4 @@ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { | ||
} | ||
var _iterator3 = _createForOfIteratorHelper(_lists.fsSyncMethods), | ||
_step3; | ||
_step3; | ||
try { | ||
@@ -92,10 +74,6 @@ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { | ||
} | ||
return function unpatch() { | ||
for (var key in bkp) { | ||
fs[key] = bkp[key]; | ||
} | ||
for (var key in bkp) fs[key] = bkp[key]; | ||
}; | ||
} | ||
; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,9 +8,5 @@ value: true | ||
exports["default"] = patchRequire; | ||
var path = _interopRequireWildcard(require("path")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var isWin32 = process.platform === 'win32'; | ||
@@ -21,3 +16,2 @@ var correctPath = isWin32 ? require('./correctPath').correctPath : function (p) { | ||
}; | ||
function stripBOM(content) { | ||
@@ -27,10 +21,7 @@ if (content.charCodeAt(0) === 0xFEFF) { | ||
} | ||
return content; | ||
} | ||
function patchRequire(vol) { | ||
var unixifyPaths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var Module = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : require('module'); | ||
if (isWin32 && unixifyPaths) { | ||
@@ -50,3 +41,2 @@ var original = vol; | ||
} | ||
function internalModuleReadFile(path) { | ||
@@ -57,3 +47,2 @@ try { | ||
} | ||
function internalModuleStat(filename) { | ||
@@ -66,13 +55,9 @@ try { | ||
} | ||
function stat(filename) { | ||
filename = path._makeLong(filename); | ||
var cache = stat.cache; | ||
if (cache !== null) { | ||
var _result = cache.get(filename); | ||
if (_result !== undefined) return _result; | ||
} | ||
var result = internalModuleStat(filename); | ||
@@ -82,12 +67,8 @@ if (cache !== null) cache.set(filename, result); | ||
} | ||
stat.cache = null; | ||
var preserveSymlinks = false; | ||
function toRealPath(requestPath) { | ||
return vol.realpathSync(requestPath); | ||
} | ||
var packageMainCache = Object.create(null); | ||
function readPackage(requestPath) { | ||
@@ -98,9 +79,6 @@ var entry = packageMainCache[requestPath]; | ||
var json = internalModuleReadFile(path._makeLong(jsonPath)); | ||
if (json === undefined) { | ||
return false; | ||
} | ||
var pkg; | ||
try { | ||
@@ -113,20 +91,14 @@ pkg = packageMainCache[requestPath] = JSON.parse(json).main; | ||
} | ||
return pkg; | ||
} | ||
function tryFile(requestPath, isMain) { | ||
var rc = stat(requestPath); | ||
if (preserveSymlinks && !isMain) { | ||
return rc === 0 && path.resolve(requestPath); | ||
} | ||
return rc === 0 && toRealPath(requestPath); | ||
} | ||
function tryExtensions(p, exts, isMain) { | ||
for (var i = 0; i < exts.length; i++) { | ||
var filename = tryFile(p + exts[i], isMain); | ||
if (filename) { | ||
@@ -136,6 +108,4 @@ return filename; | ||
} | ||
return false; | ||
} | ||
function tryPackage(requestPath, exts, isMain) { | ||
@@ -147,12 +117,8 @@ var pkg = readPackage(requestPath); | ||
} | ||
Module._extensions['.js'] = function (module, filename) { | ||
var content = vol.readFileSync(filename, 'utf8'); | ||
module._compile(stripBOM(content), filename); | ||
}; | ||
Module._extensions['.json'] = function (module, filename) { | ||
var content = vol.readFileSync(filename, 'utf8'); | ||
try { | ||
@@ -165,5 +131,3 @@ module.exports = JSON.parse(stripBOM(content)); | ||
}; | ||
var warned = true; | ||
Module._findPath = function (request, paths, isMain) { | ||
@@ -175,3 +139,2 @@ if (path.isAbsolute(request)) { | ||
} | ||
var cacheKey = request + '\x00' + (paths.length === 1 ? paths[0] : paths.join('\x00')); | ||
@@ -182,3 +145,2 @@ var entry = Module._pathCache[cacheKey]; | ||
var trailingSlash = request.length > 0 && request.charCodeAt(request.length - 1) === 47; | ||
for (var i = 0; i < paths.length; i++) { | ||
@@ -190,3 +152,2 @@ var curPath = paths[i]; | ||
var rc = stat(basePath); | ||
if (!trailingSlash) { | ||
@@ -203,3 +164,2 @@ if (rc === 0) { | ||
} | ||
if (!filename) { | ||
@@ -210,3 +170,2 @@ if (exts === undefined) exts = Object.keys(Module._extensions); | ||
} | ||
if (!filename && rc === 1) { | ||
@@ -216,3 +175,2 @@ if (exts === undefined) exts = Object.keys(Module._extensions); | ||
} | ||
if (!filename && rc === 1) { | ||
@@ -222,3 +180,2 @@ if (exts === undefined) exts = Object.keys(Module._extensions); | ||
} | ||
if (filename) { | ||
@@ -231,3 +188,2 @@ if (request === '.' && i > 0) { | ||
} | ||
Module._pathCache[cacheKey] = filename; | ||
@@ -237,5 +193,4 @@ return filename; | ||
} | ||
return false; | ||
}; | ||
} |
@@ -6,8 +6,8 @@ "use strict"; | ||
}); | ||
exports.fsAsyncMethods = exports.fsSyncMethods = exports.fsProps = void 0; | ||
exports.fsSyncMethods = exports.fsProps = exports.fsAsyncMethods = void 0; | ||
var fsProps = ['constants', 'F_OK', 'R_OK', 'W_OK', 'X_OK', 'Stats']; | ||
exports.fsProps = fsProps; | ||
var fsSyncMethods = ['renameSync', 'ftruncateSync', 'truncateSync', 'chownSync', 'fchownSync', 'lchownSync', 'chmodSync', 'fchmodSync', 'lchmodSync', 'statSync', 'lstatSync', 'fstatSync', 'linkSync', 'symlinkSync', 'readlinkSync', 'realpathSync', 'unlinkSync', 'rmdirSync', 'mkdirSync', 'mkdirpSync', 'readdirSync', 'closeSync', 'openSync', 'utimesSync', 'futimesSync', 'fsyncSync', 'writeSync', 'readSync', 'readFileSync', 'writeFileSync', 'appendFileSync', 'existsSync', 'accessSync', 'fdatasyncSync', 'mkdtempSync', 'copyFileSync', 'createReadStream', 'createWriteStream']; | ||
var fsSyncMethods = ['renameSync', 'ftruncateSync', 'truncateSync', 'chownSync', 'fchownSync', 'lchownSync', 'chmodSync', 'fchmodSync', 'lchmodSync', 'statSync', 'lstatSync', 'fstatSync', 'linkSync', 'symlinkSync', 'readlinkSync', 'realpathSync', 'unlinkSync', 'rmdirSync', 'mkdirSync', 'mkdirpSync', 'readdirSync', 'closeSync', 'openSync', 'utimesSync', 'futimesSync', 'fsyncSync', 'writeSync', 'readSync', 'readFileSync', 'writeFileSync', 'appendFileSync', 'existsSync', 'accessSync', 'fdatasyncSync', 'mkdtempSync', 'copyFileSync', 'rmSync', 'createReadStream', 'createWriteStream']; | ||
exports.fsSyncMethods = fsSyncMethods; | ||
var fsAsyncMethods = ['rename', 'ftruncate', 'truncate', 'chown', 'fchown', 'lchown', 'chmod', 'fchmod', 'lchmod', 'stat', 'lstat', 'fstat', 'link', 'symlink', 'readlink', 'realpath', 'unlink', 'rmdir', 'mkdir', 'mkdirp', 'readdir', 'close', 'open', 'utimes', 'futimes', 'fsync', 'write', 'read', 'readFile', 'writeFile', 'appendFile', 'exists', 'access', 'fdatasync', 'mkdtemp', 'copyFile', 'watchFile', 'unwatchFile', 'watch']; | ||
var fsAsyncMethods = ['rename', 'ftruncate', 'truncate', 'chown', 'fchown', 'lchown', 'chmod', 'fchmod', 'lchmod', 'stat', 'lstat', 'fstat', 'link', 'symlink', 'readlink', 'realpath', 'unlink', 'rmdir', 'mkdir', 'mkdirp', 'readdir', 'close', 'open', 'utimes', 'futimes', 'fsync', 'write', 'read', 'readFile', 'writeFile', 'appendFile', 'exists', 'access', 'fdatasync', 'mkdtemp', 'copyFile', 'rm', 'watchFile', 'unwatchFile', 'watch']; | ||
exports.fsAsyncMethods = fsAsyncMethods; |
{ | ||
"name": "fs-monkey", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Monkey patches for file system related things.", | ||
@@ -35,14 +35,14 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@babel/cli": "^7.13.14", | ||
"@babel/core": "^7.13.14", | ||
"@babel/preset-env": "^7.13.12", | ||
"@semantic-release/changelog": "5.0.1", | ||
"@semantic-release/git": "9.0.0", | ||
"@semantic-release/npm": "7.1.0", | ||
"@types/jest": "26.0.22", | ||
"@types/node": "8.10.66", | ||
"babel-jest": "26.6.3", | ||
"jest": "26.6.3", | ||
"semantic-release": "17.4.2", | ||
"source-map-support": "0.5.19" | ||
"@babel/cli": "^7.18.6", | ||
"@babel/core": "^7.18.6", | ||
"@babel/preset-env": "^7.18.6", | ||
"@semantic-release/changelog": "^6.0.1", | ||
"@semantic-release/git": "^10.0.1", | ||
"@semantic-release/npm": "^9.0.1", | ||
"@types/jest": "^28.1.4", | ||
"@types/node": "^8.10.66", | ||
"babel-jest": "^28.1.2", | ||
"jest": "^28.1.2", | ||
"semantic-release": "^19.0.3", | ||
"source-map-support": "^0.5.21" | ||
}, | ||
@@ -49,0 +49,0 @@ "release": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
21939
10