1 | "use strict";
|
2 | var _a;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.versionGteLt = exports.once = exports.getBasePathForProjectLocalDependencyResolution = exports.createProjectLocalResolveHelper = exports.attemptRequireWithV8CompileCache = exports.cachedLookup = exports.hasOwnProperty = exports.normalizeSlashes = exports.parse = exports.split = exports.assign = exports.yn = exports.createRequire = void 0;
|
5 | const module_1 = require("module");
|
6 | const ynModule = require("yn");
|
7 | const path_1 = require("path");
|
8 |
|
9 | exports.createRequire = (_a = module_1.createRequire !== null && module_1.createRequire !== void 0 ? module_1.createRequire : module_1.createRequireFromPath) !== null && _a !== void 0 ? _a : require('create-require');
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function yn(value) {
|
16 | var _a;
|
17 | return (_a = ynModule(value)) !== null && _a !== void 0 ? _a : undefined;
|
18 | }
|
19 | exports.yn = yn;
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | function assign(initialValue, ...sources) {
|
26 | for (const source of sources) {
|
27 | for (const key of Object.keys(source)) {
|
28 | const value = source[key];
|
29 | if (value !== undefined)
|
30 | initialValue[key] = value;
|
31 | }
|
32 | }
|
33 | return initialValue;
|
34 | }
|
35 | exports.assign = assign;
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | function split(value) {
|
42 | return typeof value === 'string'
|
43 | ? value.split(/ *, */g).filter((v) => v !== '')
|
44 | : undefined;
|
45 | }
|
46 | exports.split = split;
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | function parse(value) {
|
52 | return typeof value === 'string' ? JSON.parse(value) : undefined;
|
53 | }
|
54 | exports.parse = parse;
|
55 | const directorySeparator = '/';
|
56 | const backslashRegExp = /\\/g;
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | function normalizeSlashes(value) {
|
62 | return value.replace(backslashRegExp, directorySeparator);
|
63 | }
|
64 | exports.normalizeSlashes = normalizeSlashes;
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | function hasOwnProperty(object, property) {
|
70 | return Object.prototype.hasOwnProperty.call(object, property);
|
71 | }
|
72 | exports.hasOwnProperty = hasOwnProperty;
|
73 |
|
74 |
|
75 |
|
76 | function cachedLookup(fn) {
|
77 | const cache = new Map();
|
78 | return (arg) => {
|
79 | if (!cache.has(arg)) {
|
80 | const v = fn(arg);
|
81 | cache.set(arg, v);
|
82 | return v;
|
83 | }
|
84 | return cache.get(arg);
|
85 | };
|
86 | }
|
87 | exports.cachedLookup = cachedLookup;
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | function attemptRequireWithV8CompileCache(requireFn, specifier) {
|
94 | try {
|
95 | const v8CC = require('v8-compile-cache-lib').install();
|
96 | try {
|
97 | return requireFn(specifier);
|
98 | }
|
99 | finally {
|
100 | v8CC === null || v8CC === void 0 ? void 0 : v8CC.uninstall();
|
101 | }
|
102 | }
|
103 | catch (e) {
|
104 | return requireFn(specifier);
|
105 | }
|
106 | }
|
107 | exports.attemptRequireWithV8CompileCache = attemptRequireWithV8CompileCache;
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | function createProjectLocalResolveHelper(localDirectory) {
|
116 | return function projectLocalResolveHelper(specifier, fallbackToTsNodeRelative) {
|
117 | return require.resolve(specifier, {
|
118 | paths: fallbackToTsNodeRelative
|
119 | ? [localDirectory, __dirname]
|
120 | : [localDirectory],
|
121 | });
|
122 | };
|
123 | }
|
124 | exports.createProjectLocalResolveHelper = createProjectLocalResolveHelper;
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | function getBasePathForProjectLocalDependencyResolution(configFilePath, projectSearchDirOption, projectOption, cwdOption) {
|
131 | var _a;
|
132 | if (configFilePath != null)
|
133 | return (0, path_1.dirname)(configFilePath);
|
134 | return (_a = projectSearchDirOption !== null && projectSearchDirOption !== void 0 ? projectSearchDirOption : projectOption) !== null && _a !== void 0 ? _a : cwdOption;
|
135 |
|
136 |
|
137 |
|
138 | }
|
139 | exports.getBasePathForProjectLocalDependencyResolution = getBasePathForProjectLocalDependencyResolution;
|
140 |
|
141 | function once(fn) {
|
142 | let value;
|
143 | let ran = false;
|
144 | function onceFn(...args) {
|
145 | if (ran)
|
146 | return value;
|
147 | value = fn(...args);
|
148 | ran = true;
|
149 | return value;
|
150 | }
|
151 | return onceFn;
|
152 | }
|
153 | exports.once = once;
|
154 |
|
155 | function versionGteLt(version, gteRequirement, ltRequirement) {
|
156 | const [major, minor, patch, extra] = parse(version);
|
157 | const [gteMajor, gteMinor, gtePatch] = parse(gteRequirement);
|
158 | const isGte = major > gteMajor ||
|
159 | (major === gteMajor &&
|
160 | (minor > gteMinor || (minor === gteMinor && patch >= gtePatch)));
|
161 | let isLt = true;
|
162 | if (ltRequirement) {
|
163 | const [ltMajor, ltMinor, ltPatch] = parse(ltRequirement);
|
164 | isLt =
|
165 | major < ltMajor ||
|
166 | (major === ltMajor &&
|
167 | (minor < ltMinor || (minor === ltMinor && patch < ltPatch)));
|
168 | }
|
169 | return isGte && isLt;
|
170 | function parse(requirement) {
|
171 | return requirement.split(/[\.-]/).map((s) => parseInt(s, 10));
|
172 | }
|
173 | }
|
174 | exports.versionGteLt = versionGteLt;
|
175 |
|
\ | No newline at end of file |