Skip to content

Commit

Permalink
sudo on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Lobanov committed Aug 28, 2020
1 parent 90fffdb commit f927b8a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42052,6 +42052,7 @@ exports.SDKManager = void 0;
const core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(986));
const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const path_1 = __importDefault(__webpack_require__(622));
const sdk_manager_parser_1 = __webpack_require__(551);
const utils_1 = __webpack_require__(611);
Expand Down Expand Up @@ -42116,7 +42117,13 @@ class SDKManager {
};
const commandString = `${this.sdkManagerPath} ${args.join(" ")}`;
console.log(`[command]${commandString}`);
const exitCode = await exec.exec("sudo", [`"${this.sdkManagerPath}"`, ...args], options);
let exitCode;
if (os.platform() === "linux") {
exitCode = await exec.exec("sudo", [this.sdkManagerPath, ...args], options);
}
else {
exitCode = await exec.exec(`"${this.sdkManagerPath}"`, args, options);
}
if (exitCode !== 0) {
throw new Error(`'${commandString}' has finished with exit code '${exitCode}'`);
}
Expand Down
10 changes: 9 additions & 1 deletion src/sdk-manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as fs from "fs";
import * as os from "os";
import path from "path";
import { parseSDKManagerOutput, AndroidPackageInfo } from "./sdk-manager-parser";
import { splitByEOL } from "./utils";
Expand Down Expand Up @@ -76,7 +77,14 @@ export class SDKManager {
};
const commandString = `${this.sdkManagerPath} ${args.join(" ")}`;
console.log(`[command]${commandString}`);
const exitCode = await exec.exec("sudo", [`"${this.sdkManagerPath}"`, ...args], options);

let exitCode;
if (os.platform() === "linux") {
exitCode = await exec.exec("sudo", [this.sdkManagerPath, ...args], options);
} else {
exitCode = await exec.exec(`"${this.sdkManagerPath}"`, args, options);
}

if (exitCode !== 0) {
throw new Error(`'${commandString}' has finished with exit code '${exitCode}'`);
}
Expand Down

0 comments on commit f927b8a

Please sign in to comment.