Skip to content

Commit 0bb8671

Browse files
author
Maxim Lobanov
committed
fix output
1 parent c641c62 commit 0bb8671

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

dist/index.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,11 +1677,7 @@ const path_1 = __importDefault(__webpack_require__(622));
16771677
const sdk_manager_parser_1 = __webpack_require__(551);
16781678
const utils_1 = __webpack_require__(611);
16791679
class SDKManager {
1680-
constructor() {
1681-
const androidHome = process.env.ANDROID_HOME;
1682-
if (!androidHome) {
1683-
throw new Error("ANDROID_HOME env variable is not defined");
1684-
}
1680+
constructor(androidHome) {
16851681
this.sdkManagerPath = `"${path_1.default.join(androidHome, "tools", "bin", "sdkmanager")}"`;
16861682
}
16871683
async install(packageInfo) {
@@ -1704,11 +1700,11 @@ class SDKManager {
17041700
if (line === previousPrintedLine) {
17051701
return;
17061702
}
1707-
stdout += data.toString();
1703+
stdout += line;
17081704
if (printOutputInDebug) {
1709-
utils_1.splitByEOL(data.toString()).map(s => s.trim()).filter(Boolean).forEach(s => core.debug(s));
1705+
utils_1.splitByEOL(line).map(s => s.trim()).filter(Boolean).forEach(s => core.debug(s));
17101706
}
1711-
previousPrintedLine = stdout;
1707+
previousPrintedLine = line;
17121708
};
17131709
const options = {
17141710
silent: true,
@@ -1810,6 +1806,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
18101806
};
18111807
Object.defineProperty(exports, "__esModule", { value: true });
18121808
const core = __importStar(__webpack_require__(470));
1809+
const exec = __importStar(__webpack_require__(986));
18131810
const os = __importStar(__webpack_require__(87));
18141811
const sdk_manager_1 = __webpack_require__(857);
18151812
const utils_1 = __webpack_require__(611);
@@ -1825,11 +1822,15 @@ const run = async () => {
18251822
const packagesToInstall = getListInput("packages");
18261823
const cache = getBooleanInput("cache");
18271824
core.debug(String(cache));
1825+
const androidHome = process.env.ANDROID_HOME;
1826+
if (!androidHome) {
1827+
throw new Error("ANDROID_HOME env variable is not defined");
1828+
}
18281829
if (os.platform() === "linux") {
1829-
// fix permissions
1830-
// sudo chmod -R a+rwx ${ANDROID_HOME}/ndk
1830+
// fix permissions for ANDROID HOME on Hosted Ubuntu images
1831+
await exec.exec("sudo", ["chmod", "-R", "a+rwx", androidHome]);
18311832
}
1832-
const sdkmanager = new sdk_manager_1.SDKManager();
1833+
const sdkmanager = new sdk_manager_1.SDKManager(androidHome);
18331834
const packages = await sdkmanager.getAllPackagesInfo();
18341835
for (const packageName of packagesToInstall) {
18351836
const foundPackage = packages.find(p => p.name === packageName);

src/sdk-manager.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { splitByEOL } from "./utils";
77
export class SDKManager {
88
private sdkManagerPath: string;
99

10-
constructor() {
11-
const androidHome = process.env.ANDROID_HOME;
12-
if (!androidHome) { throw new Error("ANDROID_HOME env variable is not defined"); }
10+
constructor(androidHome: string) {
1311
this.sdkManagerPath = `"${path.join(androidHome, "tools", "bin", "sdkmanager")}"`;
1412
}
1513

@@ -37,11 +35,11 @@ export class SDKManager {
3735
return;
3836
}
3937

40-
stdout += data.toString();
38+
stdout += line;
4139
if (printOutputInDebug) {
42-
splitByEOL(data.toString()).map(s => s.trim()).filter(Boolean).forEach(s => core.debug(s));
40+
splitByEOL(line).map(s => s.trim()).filter(Boolean).forEach(s => core.debug(s));
4341
}
44-
previousPrintedLine = stdout;
42+
previousPrintedLine = line;
4543
};
4644
const options: exec.ExecOptions = {
4745
silent: true,

src/setup-android-tools.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as core from "@actions/core";
2+
import * as exec from "@actions/exec";
23
import * as os from "os";
34
import { SDKManager } from "./sdk-manager";
45
import { splitByEOL } from "./utils";
@@ -18,12 +19,15 @@ const run = async(): Promise<void> => {
1819
const cache = getBooleanInput("cache");
1920
core.debug(String(cache));
2021

22+
const androidHome = process.env.ANDROID_HOME;
23+
if (!androidHome) { throw new Error("ANDROID_HOME env variable is not defined"); }
24+
2125
if (os.platform() === "linux") {
22-
// fix permissions
23-
// sudo chmod -R a+rwx ${ANDROID_HOME}/ndk
26+
// fix permissions for ANDROID HOME on Hosted Ubuntu images
27+
await exec.exec("sudo", ["chmod", "-R", "a+rwx", androidHome]);
2428
}
2529

26-
const sdkmanager = new SDKManager();
30+
const sdkmanager = new SDKManager(androidHome);
2731
const packages = await sdkmanager.getAllPackagesInfo();
2832
for (const packageName of packagesToInstall) {
2933
const foundPackage = packages.find(p => p.name === packageName);

0 commit comments

Comments
 (0)