minor adjustment to readme
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / lib / requirePkg.js
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 const tslib_1 = require("tslib");
4 const errorHandler_1 = require("./errorHandler");
5 const resolve_from_1 = tslib_1.__importDefault(require("resolve-from"));
6 const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
7 /**
8  * Require package explicitly installed relative to given path.
9  * Fallback to bundled one if no package was found bottom up.
10  * @param {string} fspath file system path starting point to resolve package
11  * @param {string} pkgName package's name to require
12  * @returns module
13  */
14 function requireLocalPkg(fspath, pkgName, options = { silent: true, ignoreBundled: false }) {
15     let modulePath = resolve_from_1.default.silent(fspath, pkgName);
16     if (modulePath !== void 0) {
17         try {
18             return requireFunc(modulePath);
19         }
20         catch (e) {
21             if (!options.silent) {
22                 errorHandler_1.addToOutput(`Failed to load require ${pkgName} from ${modulePath}.${options.ignoreBundled ? `` : ` Using bundled`}`, 'Error');
23             }
24         }
25     }
26     return options.ignoreBundled ? null : requireFunc(pkgName);
27 }
28 exports.requireLocalPkg = requireLocalPkg;
29 //# sourceMappingURL=requirePkg.js.map