1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.copyPathResolve = void 0;
|
4 | const path = require("path");
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function copyPathResolve(filePath, outDir, up) {
|
12 | return path.join(outDir, dealWith(filePath, up));
|
13 | }
|
14 | exports.copyPathResolve = copyPathResolve;
|
15 | function 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 | }
|
24 | function depth(string) {
|
25 | return path.normalize(string).split(path.sep).length - 1;
|
26 | }
|