UNPKG

ts-transform-paths

Version:

[![travis](https://badgen.net/travis/OniVe/ts-transform-paths)](https://travis-ci.com/OniVe/ts-transform-paths) [![npm-version](https://badgen.net/npm/v/ts-transform-paths)](https://www.npmjs.com/package/ts-transform-paths) [![npm-downloads](https://badge

37 lines (36 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAlias = exports.ensureTrailingPathDelimiter = exports.replaceDoubleSlashes = exports.stripWildcard = void 0; const path = require("path"); const SEPARATORS = ["\\", "/"]; const WILDCARDS = ["\\*", "/*"]; function stripWildcard(path) { if (WILDCARDS.indexOf(path.slice(-2)) > -1) { return path.substring(0, path.length - 2); } return path; } exports.stripWildcard = stripWildcard; function replaceDoubleSlashes(filePath) { return path.normalize(filePath); } exports.replaceDoubleSlashes = replaceDoubleSlashes; function ensureTrailingPathDelimiter(searchPath) { if (!searchPath) { return ""; } if (SEPARATORS.indexOf(searchPath.charAt(searchPath.length - 1)) < 0) { return searchPath + path.sep; } return searchPath; } exports.ensureTrailingPathDelimiter = ensureTrailingPathDelimiter; function getAlias(requestedModule) { for (let i = 0; i < requestedModule.length; i++) { if (SEPARATORS.indexOf(requestedModule[i]) > -1) { return requestedModule.substring(0, i); } } return requestedModule; } exports.getAlias = getAlias;