UNPKG

831 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.copyPathResolve = void 0;
4const path = require("path");
5/**
6 * Helper function for returning a copy destination filename
7 *
8 * @description used in `assets-manager.ts` (copy from `copyfiles`)
9 * @see https://github.com/calvinmetcalf/copyfiles/blob/master/index.js#L22
10 */
11function copyPathResolve(filePath, outDir, up) {
12 return path.join(outDir, dealWith(filePath, up));
13}
14exports.copyPathResolve = copyPathResolve;
15function dealWith(inPath, up) {
16 if (!up) {
17 return inPath;
18 }
19 if (depth(inPath) < up) {
20 throw new Error('cant go up that far');
21 }
22 return path.join(...path.normalize(inPath).split(path.sep).slice(up));
23}
24function depth(string) {
25 return path.normalize(string).split(path.sep).length - 1;
26}