diff --git a/dist/extension.js b/dist/extension.js index 55b1bca..871e479 100644 --- a/dist/extension.js +++ b/dist/extension.js @@ -47095,14 +47095,28 @@ function activate(context) { } }); context.subscriptions.push(atest, atestRunWith, atestSample, atestMockSample, startMockServerCommand); + const os = require("os"); + const osName = os.type().toLowerCase(); + let archName = os.arch(); + switch (archName) { + case "x64": + archName = "amd64"; + break; + } + let fileSuffix = "tar.gz"; + switch (osName) { + case "windows": + fileSuffix = "zip"; + break; + } var which = require_lib4(); which("atest", { nothrow: true }).then((p) => { if (p) { startAtestServer(); } else { vscode.window.showInformationMessage("Start to install API Testing."); - https.get("https://files.m.daocloud.io/github.com/LinuxSuRen/api-testing/releases/latest/download/atest-linux-amd64.tar.gz", function(response) { - const file = fs.createWriteStream("/tmp/atest.tar.gz"); + https.get(`https://files.m.daocloud.io/github.com/LinuxSuRen/api-testing/releases/latest/download/atest-${osName}-${archName}.${fileSuffix}`, function(response) { + const file = fs.createWriteStream(`/tmp/atest.${fileSuffix}`); response.pipe(file); vscode.window.showInformationMessage("Receiving API Testing binary file."); file.on("finish", () => { @@ -47110,13 +47124,13 @@ function activate(context) { vscode.window.showInformationMessage("API Testing server downloaded."); try { fs.accessSync("/usr/local/bin", fs.constants.W_OK); - cp.execSync("tar xzvf /tmp/atest.tar.gz atest && install atest /usr/local/bin/atest"); + cp.execSync(`tar xzvf /tmp/atest.${fileSuffix} atest && install atest /usr/local/bin/atest`); startAtestServer(); } catch (err) { vscode.window.showInformationMessage("Install atest in a new terminal?", "Yes", "No").then((v) => { if (v === "Yes") { let terminal = vscode.window.createTerminal({ name: "atest" }); - terminal.sendText("tar xzvf /tmp/atest.tar.gz atest && sudo install atest /usr/local/bin/atest && rm -rf atest && sudo atest service install && sudo atest service start && exit"); + terminal.sendText(`'tar xzvf /tmp/atest.${fileSuffix} atest && sudo install atest /usr/local/bin/atest && rm -rf atest && sudo atest service install && sudo atest service start && exit`); terminal.show(); } }); diff --git a/extension.js b/extension.js index f6af9a2..6cf0eba 100644 --- a/extension.js +++ b/extension.js @@ -207,14 +207,28 @@ function activate(context) { context.subscriptions.push(atest, atestRunWith, atestSample, atestMockSample, startMockServerCommand); + const os = require('os') + const osName = os.type().toLowerCase() + let archName = os.arch() + switch (archName) { + case "x64": + archName = 'amd64' + break + } + let fileSuffix = "tar.gz" + switch (osName) { + case "windows": + fileSuffix = "zip" + break + } var which = require('which') which('atest', { nothrow: true }).then((p) => { if (p) { startAtestServer() } else { vscode.window.showInformationMessage('Start to install API Testing.') - https.get("https://files.m.daocloud.io/github.com/LinuxSuRen/api-testing/releases/latest/download/atest-linux-amd64.tar.gz", function(response) { - const file = fs.createWriteStream('/tmp/atest.tar.gz'); + https.get(`https://files.m.daocloud.io/github.com/LinuxSuRen/api-testing/releases/latest/download/atest-${osName}-${archName}.${fileSuffix}`, function(response) { + const file = fs.createWriteStream(`/tmp/atest.${fileSuffix}`); response.pipe(file); vscode.window.showInformationMessage('Receiving API Testing binary file.') @@ -226,13 +240,13 @@ function activate(context) { try { fs.accessSync('/usr/local/bin', fs.constants.W_OK); - cp.execSync('tar xzvf /tmp/atest.tar.gz atest && install atest /usr/local/bin/atest') + cp.execSync(`tar xzvf /tmp/atest.${fileSuffix} atest && install atest /usr/local/bin/atest`) startAtestServer() } catch (err) { vscode.window.showInformationMessage('Install atest in a new terminal?', 'Yes', "No").then((v)=>{ if (v === 'Yes') { let terminal=vscode.window.createTerminal({name:'atest'}) - terminal.sendText('tar xzvf /tmp/atest.tar.gz atest && sudo install atest /usr/local/bin/atest && rm -rf atest && sudo atest service install && sudo atest service start && exit') + terminal.sendText(`'tar xzvf /tmp/atest.${fileSuffix} atest && sudo install atest /usr/local/bin/atest && rm -rf atest && sudo atest service install && sudo atest service start && exit`) terminal.show() } }) diff --git a/package-lock.json b/package-lock.json index 26ec76f..3f1ba65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "api-testing", - "version": "0.0.17", + "version": "0.0.18", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "api-testing", - "version": "0.0.17", + "version": "0.0.18", "dependencies": { "@grpc/grpc-js": "~1.0.5", "@grpc/proto-loader": "~0.5.4",