mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
This commit is contained in:
parent
e74a0b82b2
commit
8d2bc289f8
6 changed files with 18 additions and 14 deletions
|
@ -159,7 +159,6 @@
|
|||
"expiry-js": "0.1.7",
|
||||
"file-loader": "4.2.0",
|
||||
"font-awesome": "4.7.0",
|
||||
"fp-ts": "^2.0.5",
|
||||
"getos": "^3.1.0",
|
||||
"glob": "^7.1.2",
|
||||
"glob-all": "^3.1.0",
|
||||
|
@ -176,7 +175,6 @@
|
|||
"https-proxy-agent": "^2.2.2",
|
||||
"inert": "^5.1.0",
|
||||
"inline-style": "^2.0.0",
|
||||
"io-ts": "^2.0.1",
|
||||
"joi": "^13.5.2",
|
||||
"jquery": "^3.4.1",
|
||||
"js-yaml": "3.13.1",
|
||||
|
|
|
@ -17,18 +17,18 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export function canRequire(cwd, entry) {
|
||||
export function canRequire(entry, cwd = require.resolve.paths(entry) || []) {
|
||||
try {
|
||||
// We will try to test if we can resolve
|
||||
// this entry through the require.resolve
|
||||
// setting as the start looking path the
|
||||
// given cwd. Require.resolve will keep
|
||||
// given cwd. That cwd variable could be
|
||||
// a path or an array of paths
|
||||
// from where Require.resolve will keep
|
||||
// looking recursively as normal starting
|
||||
// from that location.
|
||||
// from those locations.
|
||||
return require.resolve(entry, {
|
||||
paths: [
|
||||
cwd
|
||||
]
|
||||
paths: [].concat(cwd)
|
||||
});
|
||||
} catch (e) {
|
||||
return false;
|
||||
|
|
|
@ -79,7 +79,7 @@ export async function parseEntries(cwd, entries, strategy, results, wasParsed =
|
|||
const sanitizedCwd = cwd || process.cwd();
|
||||
|
||||
// Test each entry against canRequire function
|
||||
const entriesQueue = entries.map(entry => canRequire(sanitizedCwd, entry));
|
||||
const entriesQueue = entries.map(entry => canRequire(entry));
|
||||
|
||||
while(entriesQueue.length) {
|
||||
// Get the first element in the queue as
|
||||
|
|
|
@ -62,8 +62,12 @@ export async function dependenciesParseStrategy(cwd, parseSingleFile, mainEntry,
|
|||
// new dependencies
|
||||
return dependencies.reduce((filteredEntries, entry) => {
|
||||
const absEntryPath = resolve(cwd, dirname(mainEntry), entry);
|
||||
const requiredPath = canRequire(cwd, absEntryPath);
|
||||
const requiredRelativePath = canRequire(cwd, entry);
|
||||
|
||||
// NOTE: cwd for following canRequires is absEntryPath
|
||||
// because we should start looking from there
|
||||
const requiredPath = canRequire(absEntryPath, absEntryPath);
|
||||
const requiredRelativePath = canRequire(entry, absEntryPath);
|
||||
|
||||
const isRelativeFile = !isAbsolute(entry);
|
||||
const isNodeModuleDep = isRelativeFile && !requiredPath && requiredRelativePath;
|
||||
const isNewEntry = isRelativeFile && requiredPath;
|
||||
|
|
|
@ -59,8 +59,8 @@ describe('Code Parser Strategies', () => {
|
|||
cb(null, `require('dep_from_node_modules')`);
|
||||
});
|
||||
|
||||
canRequire.mockImplementation((mockCwd, entry) => {
|
||||
if (entry === `${mockCwd}dep1/dep_from_node_modules`) {
|
||||
canRequire.mockImplementation((entry, cwd) => {
|
||||
if (entry === `${cwd}dep1/dep_from_node_modules`) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ describe('Code Parser Strategies', () => {
|
|||
cb(null, `require('./relative_dep')`);
|
||||
});
|
||||
|
||||
canRequire.mockImplementation((mockCwd, entry) => {
|
||||
canRequire.mockImplementation((entry) => {
|
||||
if (entry === `${mockCwd}dep1/relative_dep`) {
|
||||
return `${entry}/index.js`;
|
||||
}
|
||||
|
|
|
@ -240,6 +240,7 @@
|
|||
"file-type": "^10.9.0",
|
||||
"font-awesome": "4.7.0",
|
||||
"formsy-react": "^1.1.5",
|
||||
"fp-ts": "^2.0.5",
|
||||
"geojson-rewind": "^0.3.1",
|
||||
"get-port": "4.2.0",
|
||||
"getos": "^3.1.0",
|
||||
|
@ -261,6 +262,7 @@
|
|||
"immer": "^1.5.0",
|
||||
"inline-style": "^2.0.0",
|
||||
"intl": "^1.2.5",
|
||||
"io-ts": "^2.0.1",
|
||||
"isbinaryfile": "4.0.2",
|
||||
"isomorphic-git": "0.55.5",
|
||||
"joi": "^13.5.2",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue