UNPKG

@typed/content-hash

Version:

Content hash a directory of HTML/JS/CSS files and other static assets

22 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolvePathFromSourceFile = void 0; const tslib_1 = require("tslib"); const Env_1 = require("@typed/fp/Env"); const function_1 = require("fp-ts/function"); const O = (0, tslib_1.__importStar)(require("fp-ts/Option")); const isExternalUrl_1 = require("./isExternalUrl"); const resolvePackage_1 = require("./resolvePackage"); function resolvePathFromSourceFile(options) { const { moduleSpecifier, pathsResolver } = options; const match = (0, function_1.pipe)(moduleSpecifier, O.fromPredicate(pathsResolver.isInPaths), O.chain(pathsResolver.resolvePath)); if (O.isSome(match)) { return (0, Env_1.of)(O.some(match.value)); } if ((0, isExternalUrl_1.isExternalUrl)(moduleSpecifier)) { return (0, Env_1.of)(O.none); } return (0, Env_1.fromIO)(() => O.some((0, resolvePackage_1.resolvePackage)(options))); } exports.resolvePathFromSourceFile = resolvePathFromSourceFile; //# sourceMappingURL=resolvePathFromSourceFile.js.map