From 4be57d5c217574083cff1132b1e357c5b304c331 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 17 Jul 2020 15:54:58 +0900 Subject: [PATCH 1/2] Simplify custom repository related code Signed-off-by: Sora Morimoto --- src/installer.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/installer.ts b/src/installer.ts index e888fea5..b500f9f5 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -26,9 +26,9 @@ function getOpamDownloadUrl(version: string, filename: string) { async function acquireOpamWindows(version: string, customRepository: string) { const repository = - customRepository === "" - ? "https://github.com/fdopen/opam-repository-mingw.git#opam2" - : customRepository; + customRepository || + "https://github.com/fdopen/opam-repository-mingw.git#opam2"; + let downloadPath; try { downloadPath = await tc.downloadTool("https://cygwin.com/setup-x86_64.exe"); @@ -57,9 +57,8 @@ async function acquireOpamLinux(version: string, customRepository: string) { const fileName = getOpamFileName(opamVersion); const downloadUrl = getOpamDownloadUrl(opamVersion, fileName); const repository = - customRepository === "" - ? "https://github.com/ocaml/opam-repository.git" - : customRepository; + customRepository || "https://github.com/ocaml/opam-repository.git"; + let downloadPath; try { downloadPath = await tc.downloadTool(downloadUrl); @@ -85,9 +84,8 @@ async function acquireOpamLinux(version: string, customRepository: string) { async function acquireOpamDarwin(version: string, customRepository: string) { const repository = - customRepository === "" - ? "https://github.com/ocaml/opam-repository.git" - : customRepository; + customRepository || "https://github.com/ocaml/opam-repository.git"; + await exec("brew", ["install", "opam"]); await exec("opam", ["init", "-yav", repository]); await exec(path.join(__dirname, "install-ocaml-unix.sh"), [version]); From 88145d8a79f69d298731645526be792cc8bf2efb Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 17 Jul 2020 15:55:20 +0900 Subject: [PATCH 2/2] yarn build Signed-off-by: Sora Morimoto --- lib/index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/index.js b/lib/index.js index 72837c5e..653aea44 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4951,9 +4951,8 @@ function acquireOpamWindows(version, customRepository) { return __generator(this, function (_a) { switch (_a.label) { case 0: - repository = customRepository === "" - ? "https://github.com/fdopen/opam-repository-mingw.git#opam2" - : customRepository; + repository = customRepository || + "https://github.com/fdopen/opam-repository-mingw.git#opam2"; _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); @@ -4992,9 +4991,7 @@ function acquireOpamLinux(version, customRepository) { opamVersion = "2.0.7"; fileName = getOpamFileName(opamVersion); downloadUrl = getOpamDownloadUrl(opamVersion, fileName); - repository = customRepository === "" - ? "https://github.com/ocaml/opam-repository.git" - : customRepository; + repository = customRepository || "https://github.com/ocaml/opam-repository.git"; _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); @@ -5035,9 +5032,7 @@ function acquireOpamDarwin(version, customRepository) { return __generator(this, function (_a) { switch (_a.label) { case 0: - repository = customRepository === "" - ? "https://github.com/ocaml/opam-repository.git" - : customRepository; + repository = customRepository || "https://github.com/ocaml/opam-repository.git"; return [4 /*yield*/, exec_1.exec("brew", ["install", "opam"])]; case 1: _a.sent();