Innovenergy_trunk/frontend/node_modules/testcafe-hammerhead/lib/request-pipeline/file-request/create-resource.js

25 lines
999 B
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const filesystem_resource_1 = __importDefault(require("./filesystem-resource"));
const asar_resource_1 = __importDefault(require("./asar-resource"));
function isFileNotExists(errCode) {
return errCode === 'ENOENT' ||
errCode === 'ENOTDIR'; // NOTE: found it (ENOTDIR) on travis server tests (GH-2043 PR)
}
async function createResource(path) {
let resource = new filesystem_resource_1.default(path);
await resource.init();
if (resource.error && isFileNotExists(resource.error.code)) {
const asarResource = new asar_resource_1.default(path);
await asarResource.init();
if (asarResource.isArchiveFound)
resource = asarResource;
}
return resource;
}
exports.default = createResource;module.exports = exports.default;