Skip to content

Commit

Permalink
Update: not invoke getRootDir in some specific case
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed Mar 23, 2022
1 parent 7c9d5a8 commit c90d470
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/core/core/src/resolveOptions.js
Expand Up @@ -50,22 +50,18 @@ export default async function resolveOptions(
entries = [path.resolve(inputCwd, initialOptions.entries)];
}

let shouldMakeEntryReferFolder = false;
// if entries have the only one entry and the one is not glob and refers to directory, we need to make the entry refer to some file.
let entriesRefersEntryRoot = false;
// if entries have the only one entry and the one is not glob and refers to directory, entries already refers to entry root directory
if (entries.length === 1 && !isGlob(entries[0])) {
let [entry] = entries;
try {
shouldMakeEntryReferFolder = (await inputFS.stat(entry)).isDirectory();
entriesRefersEntryRoot = (await inputFS.stat(entry)).isDirectory();
} catch {
// ignore failing stat call
}
}

// getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user".
// Instead we need to make the the entry refer to some file inside the specified folders if entries refers to the directory.
let entryRoot = getRootDir(
shouldMakeEntryReferFolder ? [path.join(entries[0], 'index')] : entries,
);
let entryRoot = entriesRefersEntryRoot ? entries[0] : getRootDir(entries);
let projectRootFile =
(await resolveConfig(
inputFS,
Expand Down

0 comments on commit c90d470

Please sign in to comment.