UNPKG

stryker-webpack

Version:

[preview] A plugin for Webpack-based projects using Stryker

121 lines 4.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var errors = require("errno"); /* istanbul ignore next */ var HybridFs = /** @class */ (function () { function HybridFs(fs, memoryFs) { var _this = this; this.mkdirpSync = function (path) { return _this.memoryFs.mkdirpSync(path); }; this.mkdirp = function (path, callback) { return _this.memoryFs.mkdirp(path, callback); }; this.mkdirSync = function (path) { return _this.memoryFs.mkdirSync(path); }; this.mkdir = function (path, optArgs, callback) { return _this.memoryFs.mkdir(path, optArgs, callback); }; this.rmdirSync = function (path) { return _this.memoryFs.rmdirSync(path); }; this.rmdir = function (path, callback) { return _this.memoryFs.rmdir(path, callback); }; this.unlinkSync = function (path) { return _this.memoryFs.unlinkSync(path); }; this.unlink = function (path, callback) { return _this.memoryFs.unlink(path, callback); }; this.readlinkSync = function (path) { return _this.memoryFs.readlinkSync(path); }; this.readlink = function (path, callback) { return _this.memoryFs.readlink(path, callback); }; this.writeFileSync = function (path, content, optionsOrEncoding) { return _this.memoryFs.writeFileSync(path, content, optionsOrEncoding); }; this.writeFile = function (path, content, optionsOrEncoding, callback) { return _this.memoryFs.writeFile(path, content, optionsOrEncoding, callback); }; this.createReadStream = function (path, options) { return _this.memoryFs.createReadStream(path, options); }; this.createWriteStream = function (path) { return _this.memoryFs.createWriteStream(path); }; this.join = function (path, request) { return _this.memoryFs.join(path, request); }; this.pathToArray = function (path) { return _this.memoryFs.pathToArray(path); }; this.normalize = function (path) { return _this.memoryFs.normalize(path); }; this.fs = fs; this.memoryFs = memoryFs; } HybridFs.prototype.readFileSync = function (path, optionsOrEncoding) { try { return this.memoryFs.readFileSync(path, optionsOrEncoding); } catch (err) { if (err.code == errors.code.ENOENT.code) { return this.fs.readFileSync(path, optionsOrEncoding); } else { throw err; } } }; HybridFs.prototype.readFile = function (path, optArg, callback) { var _this = this; if (!callback) { callback = optArg; optArg = undefined; } this.memoryFs.readFile(path, optArg, function (err, file) { if (err) { _this.fs.readFile(path, optArg, callback); } else { callback(err, file); } }); }; HybridFs.prototype.readdirSync = function (path) { try { return this.memoryFs.readdirSync(path); } catch (err) { if (err.code === errors.code.ENOTDIR) { return this.fs.readdirSync(path); } else { throw err; } } }; HybridFs.prototype.readdir = function (path, callback) { var _this = this; this.memoryFs.readdir(path, function (err, file) { if (err) { _this.fs.readdir(path, callback); } else { callback(err, file); } }); }; HybridFs.prototype.existsSync = function (path) { try { return this.memoryFs.existsSync(path); } catch (err) { return this.fs.existsSync(path); } }; HybridFs.prototype.exists = function (path, callback) { var _this = this; this.memoryFs.exists(path, function (err) { if (err) { _this.fs.exists(path, callback); } else { callback(); } }); }; HybridFs.prototype.statSync = function (path) { try { return this.memoryFs.statSync(path); } catch (err) { return this.fs.statSync(path); } }; HybridFs.prototype.stat = function (path, callback) { var _this = this; this.memoryFs.stat(path, function (err, stats) { if (err) { _this.fs.stat(path, callback); } else { callback(err, stats); } }); }; return HybridFs; }()); exports.default = HybridFs; //# sourceMappingURL=HybridFs.js.map