UNPKG

795 BJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.default = void 0;
5
6// This module is also copied into the .cache directory some modules copied there
7// from cache-dir can also use this module.
8var _default = (moduleName, err) => {
9 // PnP will return the following code when a require is allowed per the
10 // dependency tree rules but the requested file doesn't exist
11 if (err.code === `QUALIFIED_PATH_RESOLUTION_FAILED` || err.pnpCode === `QUALIFIED_PATH_RESOLUTION_FAILED`) {
12 return true;
13 }
14
15 const regex = new RegExp(`Error:\\s(\\S+\\s)?[Cc]annot find module\\s.${moduleName.replace(/[-/\\^$*+?.()|[\]{}]/g, `\\$&`)}`);
16 const firstLine = err.toString().split(`\n`)[0];
17 return regex.test(firstLine);
18};
19
20exports.default = _default;
21//# sourceMappingURL=test-require-error.js.map
\No newline at end of file