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 6adc8a4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 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 @@ -51,10 +51,7 @@ async function getDependenciesCached(
);
}

async function getDependencies(
elmJsonPath /*: string */
) /*: Promise<string> */ {
const elmJsonConfig = fs.readFileSync(elmJsonPath, 'utf8');
async function getDependencies(elmJson /*: string */) /*: Promise<string> */ {
const useTest = true;
const extra = {
'elm/core': '1.0.0 <= v < 2.0.0',
Expand All @@ -66,7 +63,7 @@ async function getDependencies(
try {
DependencyProvider.clearListVersionsMemoCacheBeforeSolve();
solution = wasm.solve_deps(
elmJsonConfig,
JSON.stringify(elmJson),
useTest,
extra,
DependencyProvider.fetchElmJsonOffline,
Expand All @@ -80,7 +77,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 6adc8a4

Please sign in to comment.