Skip to content

Commit

Permalink
Fix install
Browse files Browse the repository at this point in the history
  • Loading branch information
wallydz committed Mar 14, 2020
1 parent e5ee5a7 commit 6a69f60
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/sdk-js/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ import request from "request-promise-native";
import progress from "request-progress";
import isInstalled from "./is-installed";
import lastVersion from "./last-version";
import { repository } from "../package.json";

const installEmitter = new EventEmitter();

let command = "open";

if (process.platform === "win32") {
command = "start";
}

if (process.platform === "linux") {
command = "pkexec";
}
Expand Down Expand Up @@ -50,7 +45,7 @@ export default async installPath => {

progress(
request(
`http://vpnhtsoftware.s3.amazonaws.com/${appVersion}/VPNht-${appVersion}.${extension}`
`https://vpnhtsoftware.s3.amazonaws.com/${appVersion}/VPNht-${appVersion}.${extension}`
)
)
.on("progress", function(state) {
Expand All @@ -73,6 +68,21 @@ export default async installPath => {
outFile
]);
}
} else if (process.platform === "win32") {
let tries = 5;
const trySpawn = () => {
try {
tries--;
execFileSync(outFile);
} catch (err) {
if ((err.code === "ETXTBSY" || err.code === "EBUSY") && tries) {
setTimeout(() => {
trySpawn();
}, 2000);
}
}
};
trySpawn();
} else {
execFileSync(command, [outFile]);
}
Expand Down

0 comments on commit 6a69f60

Please sign in to comment.