source: imaps-frontend/node_modules/@babel/helper-define-polyfill-provider/lib/node/dependencies.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.2 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.has = has;
5exports.laterLogMissing = laterLogMissing;
6exports.logMissing = logMissing;
7exports.resolve = resolve;
8var _path = _interopRequireDefault(require("path"));
9var _lodash = _interopRequireDefault(require("lodash.debounce"));
10var _resolve = _interopRequireDefault(require("resolve"));
11var _module = require("module");
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13const nativeRequireResolve = parseFloat(process.versions.node) >= 8.9;
14// eslint-disable-line
15
16function myResolve(name, basedir) {
17 if (nativeRequireResolve) {
18 return require.resolve(name, {
19 paths: [basedir]
20 }).replace(/\\/g, "/");
21 } else {
22 return _resolve.default.sync(name, {
23 basedir
24 }).replace(/\\/g, "/");
25 }
26}
27function resolve(dirname, moduleName, absoluteImports) {
28 if (absoluteImports === false) return moduleName;
29 let basedir = dirname;
30 if (typeof absoluteImports === "string") {
31 basedir = _path.default.resolve(basedir, absoluteImports);
32 }
33 try {
34 return myResolve(moduleName, basedir);
35 } catch (err) {
36 if (err.code !== "MODULE_NOT_FOUND") throw err;
37 throw Object.assign(new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), {
38 code: "BABEL_POLYFILL_NOT_FOUND",
39 polyfill: moduleName,
40 dirname
41 });
42 }
43}
44function has(basedir, name) {
45 try {
46 myResolve(name, basedir);
47 return true;
48 } catch (_unused) {
49 return false;
50 }
51}
52function logMissing(missingDeps) {
53 if (missingDeps.size === 0) return;
54 const deps = Array.from(missingDeps).sort().join(" ");
55 console.warn("\nSome polyfills have been added but are not present in your dependencies.\n" + "Please run one of the following commands:\n" + `\tnpm install --save ${deps}\n` + `\tyarn add ${deps}\n`);
56 process.exitCode = 1;
57}
58let allMissingDeps = new Set();
59const laterLogMissingDependencies = (0, _lodash.default)(() => {
60 logMissing(allMissingDeps);
61 allMissingDeps = new Set();
62}, 100);
63function laterLogMissing(missingDeps) {
64 if (missingDeps.size === 0) return;
65 missingDeps.forEach(name => allMissingDeps.add(name));
66 laterLogMissingDependencies();
67}
Note: See TracBrowser for help on using the repository browser.