From d67a46fb7dd98ad675320f969a9a617542d27f08 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Sun, 10 Nov 2024 04:22:47 +0900 Subject: [PATCH] Faster set-up when a cache hit occurs Signed-off-by: Sora Morimoto --- dist/index.js | 30 +++++++++++++++++---------- packages/setup-ocaml/src/installer.ts | 9 +++++--- packages/setup-ocaml/src/opam.ts | 6 ++++++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index f16d6e01..1a2f8fda 100644 --- a/dist/index.js +++ b/dist/index.js @@ -138147,6 +138147,11 @@ async function repositoryRemoveAll() { } }); } +async function update() { + await lib_core.group("Update the list of available opam packages", async () => { + await (0,lib_exec.exec)("opam", ["update"]); + }); +} ;// CONCATENATED MODULE: external "node:fs/promises" const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs/promises"); @@ -144289,7 +144294,7 @@ function getParse(parser) { // Add conent to new root element const root = new Document([]); // Update the DOM using the root - update(doc, root); + parse_update(doc, root); return root; }; } @@ -144300,7 +144305,7 @@ function getParse(parser) { * @param parent - The new parent. * @returns The parent node. */ -function update(newChilds, parent) { +function parse_update(newChilds, parent) { // Normalize const arr = Array.isArray(newChilds) ? newChilds : [newChilds]; // Update parent @@ -144633,7 +144638,7 @@ const wrap = _wrap((el, elInsertLocation, wrapperDom) => { return; const siblings = parent.children; const index = siblings.indexOf(el); - update([el], elInsertLocation); + parse_update([el], elInsertLocation); /* * The previous operation removed the current element from the `siblings` * array, so the `dom` array can be inserted without removing any @@ -144687,8 +144692,8 @@ const wrap = _wrap((el, elInsertLocation, wrapperDom) => { const wrapInner = _wrap((el, elInsertLocation, wrapperDom) => { if (!hasChildren(el)) return; - update(el.children, elInsertLocation); - update(wrapperDom, el); + parse_update(el.children, elInsertLocation); + parse_update(wrapperDom, el); }); /** * The .unwrap() function, removes the parents of the set of matched elements @@ -145053,7 +145058,7 @@ function replaceWith(content) { * In the case that `dom` contains nodes that already exist in other * structures, ensure those nodes are properly removed. */ - update(dom, null); + parse_update(dom, null); const index = siblings.indexOf(el); // Completely remove old element uniqueSplice(siblings, index, 1, dom, parent); @@ -145104,7 +145109,7 @@ function manipulation_html(str) { const content = isCheerio(str) ? str.toArray() : this._parse(`${str}`, this.options, false, el).children; - update(content, el); + parse_update(content, el); }); } /** @@ -145133,7 +145138,7 @@ function manipulation_text(str) { child.next = child.prev = child.parent = null; } const textNode = new node_Text(`${str}`); - update(textNode, el); + parse_update(textNode, el); }); } /** @@ -156948,13 +156953,16 @@ async function installer() { lib_core.addPath(CYGWIN_ROOT_BIN); } await setupOpam(); - await repositoryRemoveAll(); - await repositoryAddAll(OPAM_REPOSITORIES); - const ocamlCompiler = await RESOLVED_COMPILER; if (!opamCacheHit) { + await repositoryRemoveAll(); + await repositoryAddAll(OPAM_REPOSITORIES); + const ocamlCompiler = await RESOLVED_COMPILER; await installOcaml(ocamlCompiler); await saveOpamCache(); } + else { + await update(); + } if (DUNE_CACHE) { await restoreDuneCache(); await installDune(); diff --git a/packages/setup-ocaml/src/installer.ts b/packages/setup-ocaml/src/installer.ts index 26f65490..a2aea3bb 100644 --- a/packages/setup-ocaml/src/installer.ts +++ b/packages/setup-ocaml/src/installer.ts @@ -25,6 +25,7 @@ import { repositoryAddAll, repositoryRemoveAll, setupOpam, + update, } from "./opam.js"; import { retrieveOpamLocalPackages } from "./packages.js"; import { setupCygwin } from "./windows.js"; @@ -69,12 +70,14 @@ export async function installer() { core.addPath(CYGWIN_ROOT_BIN); } await setupOpam(); - await repositoryRemoveAll(); - await repositoryAddAll(OPAM_REPOSITORIES); - const ocamlCompiler = await RESOLVED_COMPILER; if (!opamCacheHit) { + await repositoryRemoveAll(); + await repositoryAddAll(OPAM_REPOSITORIES); + const ocamlCompiler = await RESOLVED_COMPILER; await installOcaml(ocamlCompiler); await saveOpamCache(); + } else { + await update(); } if (DUNE_CACHE) { await restoreDuneCache(); diff --git a/packages/setup-ocaml/src/opam.ts b/packages/setup-ocaml/src/opam.ts index 6f1bfc6d..2dba4aa1 100644 --- a/packages/setup-ocaml/src/opam.ts +++ b/packages/setup-ocaml/src/opam.ts @@ -194,3 +194,9 @@ export async function repositoryRemoveAll() { } }); } + +export async function update() { + await core.group("Update the list of available opam packages", async () => { + await exec("opam", ["update"]); + }); +}