Skip to content

Commit

Permalink
Avoid reading elm.json again
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Jan 2, 2022
1 parent df6e9c9 commit bfc3e44
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/Solve.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function getDependenciesCached(
}
}

const dependencies = await getDependencies(ElmJson.getPath(project.rootDir));
const dependencies = await getDependencies(project.elmJson);

fs.writeFileSync(cacheFile, dependencies);

Expand All @@ -52,9 +52,8 @@ async function getDependenciesCached(
}

async function getDependencies(
elmJsonPath /*: string */
elmJson /*: typeof ElmJson.ElmJson */
) /*: Promise<string> */ {
const elmJsonConfig = fs.readFileSync(elmJsonPath, 'utf8');
const useTest = true;
const extra = {
'elm/core': '1.0.0 <= v < 2.0.0',
Expand All @@ -66,7 +65,7 @@ async function getDependencies(
try {
DependencyProvider.clearListVersionsMemoCacheBeforeSolve();
solution = wasm.solve_deps(
elmJsonConfig,
JSON.stringify(elmJson),
useTest,
extra,
DependencyProvider.fetchElmJsonOffline,
Expand All @@ -80,7 +79,7 @@ async function getDependencies(
DependencyProvider.clearListVersionsMemoCacheBeforeSolve();
// Solve again, in online mode.
solution = wasm.solve_deps(
elmJsonConfig,
JSON.stringify(elmJson),
useTest,
extra,
DependencyProvider.fetchElmJsonOnline,
Expand Down

0 comments on commit bfc3e44

Please sign in to comment.