From 0401063eb2ee903d3457e49d56b636af23a63726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AE=80=E9=9D=99=E5=87=A1?= <30424139+wtto00@users.noreply.github.com> Date: Sat, 16 Sep 2023 00:59:06 +0800 Subject: [PATCH] chore: ci --- .github/workflows/test.yml | 4 +++- spec/constructor.test.ts | 20 +++++++++++--------- src/util.ts | 1 - 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b2e53b..cb60a47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [14, 16, 18, 20] + node: [16, 18, 20] + env: + GITHUB_CI: true steps: - name: Checkout Code uses: actions/checkout@v3 diff --git a/spec/constructor.test.ts b/spec/constructor.test.ts index fe27179..f7bfbf8 100644 --- a/spec/constructor.test.ts +++ b/spec/constructor.test.ts @@ -1,6 +1,8 @@ import path from "path"; import Android from "../src/index.js"; +const cmdLinePath = process.env.GITHUB_CI ? "cmdline-tools" : "cmdline-tools/latest"; + describe("constructor", () => { test("constructor", () => { const androidHome = process.env.ANDROID_HOME || ""; @@ -20,35 +22,35 @@ describe("constructor", () => { "adb", "avdmanager", "sdkmanager", - "emulator", + process.env.GITHUB_CI ? path.resolve(androidHome, "emulator/emulator111") : "emulator", ]); }); test("constructor with custom path", () => { const androidHome = process.env.ANDROID_HOME || ""; const android = new Android({ - avdmanager: "cmdline-tools/latest/bin/avdmanager", - sdkmanager: "cmdline-tools/latest/bin/sdkmanager", + avdmanager: `${cmdLinePath}/bin/avdmanager`, + sdkmanager: `${cmdLinePath}/bin/sdkmanager`, adb: "platform-tools/adb", emulator: "emulator/emulator", }); expect([android.adbBin, android.avdmanagerBin, android.sdkmanagerBin, android.emulatorBin]).toEqual([ path.resolve(androidHome, "platform-tools/adb"), - path.resolve(androidHome, "cmdline-tools/latest/bin/avdmanager"), - path.resolve(androidHome, "cmdline-tools/latest/bin/sdkmanager"), + path.resolve(androidHome, `${cmdLinePath}/bin/avdmanager`), + path.resolve(androidHome, `${cmdLinePath}/bin/sdkmanager`), path.resolve(androidHome, "emulator/emulator"), ]); }); test("constructor with custom executable file environment variable", () => { const androidHome = process.env.ANDROID_HOME || ""; - process.env.avdmanagerBin = path.resolve(androidHome, "cmdline-tools/latest/bin/avdmanager"); - process.env.sdkmanagerBin = path.resolve(androidHome, "cmdline-tools/latest/bin/sdkmanager"); + process.env.avdmanagerBin = path.resolve(androidHome, `${cmdLinePath}/bin/avdmanager`); + process.env.sdkmanagerBin = path.resolve(androidHome, `${cmdLinePath}/bin/sdkmanager`); const android = new Android(); expect([android.adbBin, android.avdmanagerBin, android.sdkmanagerBin, android.emulatorBin]).toEqual([ path.resolve(androidHome, "platform-tools/adb"), - path.resolve(androidHome, "cmdline-tools/latest/bin/avdmanager"), - path.resolve(androidHome, "cmdline-tools/latest/bin/sdkmanager"), + path.resolve(androidHome, `${cmdLinePath}/bin/avdmanager`), + path.resolve(androidHome, `${cmdLinePath}/bin/sdkmanager`), path.resolve(androidHome, "emulator/emulator"), ]); }); diff --git a/src/util.ts b/src/util.ts index 1b84259..bdefd04 100644 --- a/src/util.ts +++ b/src/util.ts @@ -39,7 +39,6 @@ export function spawnExec(command: string, timeout = 60000) { proc.on("close", (code) => { clearTimeout(clock); if (code) { - console.log('proc.killed',proc.killed); reject(Error(error)); } else { proc.output = output;