Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Commit 02f94b1

Browse files
committed
cleanup imports in installer.ts
1 parent 7b135cc commit 02f94b1

File tree

2 files changed

+68
-68
lines changed

2 files changed

+68
-68
lines changed

lib/installer.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1313
};
1414
Object.defineProperty(exports, "__esModule", { value: true });
1515
const os_1 = __importDefault(require("os"));
16-
const fs_1 = require("fs");
1716
const path_1 = __importDefault(require("path"));
17+
const fs_1 = require("fs");
1818
const url_1 = require("url");
1919
const util_1 = require("util");
20-
const core_1 = __importDefault(require("@actions/core"));
21-
const io_1 = __importDefault(require("@actions/io"));
22-
const exec_1 = __importDefault(require("@actions/exec"));
20+
const core_1 = require("@actions/core");
21+
const io_1 = require("@actions/io");
22+
const exec_1 = require("@actions/exec");
2323
const cache_1 = require("@actions/cache");
2424
const linuxplatform_1 = __importDefault(require("./platforms/linuxplatform"));
2525
const androidplatform_1 = __importDefault(require("./platforms/androidplatform"));
@@ -73,44 +73,44 @@ let Installer = /** @class */ (() => {
7373
// try to get Qt from cache, unless clean is specified
7474
let toolPath = null;
7575
if (clean != "true") {
76-
core_1.default.debug(`Trying to restore Qt from cache with key: ${this._cacheKey} `);
76+
core_1.debug(`Trying to restore Qt from cache with key: ${this._cacheKey} `);
7777
const hitKey = yield cache_1.restoreCache([Installer.CacheDir], this._cacheKey);
7878
if (hitKey && (yield exists(path_1.default.join(Installer.CacheDir, "bin", this._platform.qmakeName())))) {
7979
toolPath = path_1.default.resolve(Installer.CacheDir);
80-
core_1.default.debug(`Restored Qt from cache to path: ${toolPath}`);
80+
core_1.debug(`Restored Qt from cache to path: ${toolPath}`);
8181
}
8282
}
8383
// download, extract, cache
8484
if (!toolPath) {
85-
core_1.default.debug('Downloading and installing Qt');
85+
core_1.debug('Downloading and installing Qt');
8686
toolPath = yield this.acquireQt(this.parseList(packages, ','), this.parseList(deepSrc, ' '), this.parseList(flatSrc, ' '));
87-
core_1.default.debug(`Caching Qt with key: ${this._cacheKey}`);
87+
core_1.debug(`Caching Qt with key: ${this._cacheKey}`);
8888
yield this._platform.runPostInstall(false, toolPath);
8989
yield cache_1.saveCache([toolPath], this._cacheKey);
9090
}
9191
else
9292
yield this._platform.runPostInstall(true, toolPath);
93-
core_1.default.info('Using Qt installation: ' + toolPath);
93+
core_1.info('Using Qt installation: ' + toolPath);
9494
// generate qdep prf
9595
yield this.generateQdepPrf(toolPath);
9696
// update output / env vars
97-
core_1.default.setOutput("qtdir", toolPath);
98-
core_1.default.addPath(path_1.default.join(toolPath, "bin"));
97+
core_1.setOutput("qtdir", toolPath);
98+
core_1.addPath(path_1.default.join(toolPath, "bin"));
9999
this._platform.addExtraEnvVars(toolPath);
100100
// log stuff
101-
yield exec_1.default.exec("qmake", ["-version"]);
102-
yield exec_1.default.exec("qmake", ["-query"]);
101+
yield exec_1.exec("qmake", ["-version"]);
102+
yield exec_1.exec("qmake", ["-query"]);
103103
// set outputs
104-
core_1.default.setOutput("shell", this._platform.shellName());
105-
core_1.default.setOutput("make", this._platform.makeName());
106-
core_1.default.setOutput("tests", String(this.shouldTest()));
107-
core_1.default.setOutput("testflags", this._platform.testFlags());
104+
core_1.setOutput("shell", this._platform.shellName());
105+
core_1.setOutput("make", this._platform.makeName());
106+
core_1.setOutput("tests", String(this.shouldTest()));
107+
core_1.setOutput("testflags", this._platform.testFlags());
108108
// set install dir, create artifact symlink
109109
const iPath = this._platform.installDirs(toolPath);
110-
yield io_1.default.mkdirP(iPath[0]);
110+
yield io_1.mkdirP(iPath[0]);
111111
const instPath = path_1.default.join(iPath[0], os_1.default.platform() == "win32" ? toolPath.substr(3) : toolPath.substr(1), "..", "..");
112-
core_1.default.setOutput('outdir', instPath);
113-
core_1.default.setOutput('installdir', iPath[1]);
112+
core_1.setOutput('outdir', instPath);
113+
core_1.setOutput('installdir', iPath[1]);
114114
});
115115
}
116116
parseList(list, seperator) {
@@ -139,12 +139,12 @@ let Installer = /** @class */ (() => {
139139
}
140140
installQdep() {
141141
return __awaiter(this, void 0, void 0, function* () {
142-
const pythonPath = yield io_1.default.which('python', true);
143-
core_1.default.debug(`Using python: ${pythonPath}`);
144-
yield exec_1.default.exec(pythonPath, ["-m", "pip", "install", "qdep"]);
145-
const qdepPath = yield io_1.default.which('qdep', true);
146-
yield exec_1.default.exec(qdepPath, ["--version"]);
147-
core_1.default.info("Installed qdep");
142+
const pythonPath = yield io_1.which('python', true);
143+
core_1.debug(`Using python: ${pythonPath}`);
144+
yield exec_1.exec(pythonPath, ["-m", "pip", "install", "qdep"]);
145+
const qdepPath = yield io_1.which('qdep', true);
146+
yield exec_1.exec(qdepPath, ["--version"]);
147+
core_1.info("Installed qdep");
148148
});
149149
}
150150
acquireQt(packages, deepSrc, flatSrc) {
@@ -156,7 +156,7 @@ let Installer = /** @class */ (() => {
156156
for (const src of flatSrc)
157157
yield this._downloader.addSource(new url_1.URL(src), false);
158158
// add packages
159-
core_1.default.debug(`Available modules: ${this._downloader.modules().join(", ")}`);
159+
core_1.debug(`Available modules: ${this._downloader.modules().join(", ")}`);
160160
for (const pkg of this._platform.extraTools())
161161
this._downloader.addDownload(pkg, true);
162162
for (const pkg of packages)
@@ -168,22 +168,22 @@ let Installer = /** @class */ (() => {
168168
// move tools
169169
const oldToolPath = path_1.default.join(installPath, "Tools");
170170
if (yield exists(oldToolPath))
171-
yield io_1.default.mv(oldToolPath, path_1.default.join(dataPath, "Tools"));
171+
yield io_1.mv(oldToolPath, path_1.default.join(dataPath, "Tools"));
172172
// move out of install dir to seperate dir
173-
yield io_1.default.rmRF(Installer.CacheDir);
174-
yield io_1.default.mv(dataPath, Installer.CacheDir);
173+
yield io_1.rmRF(Installer.CacheDir);
174+
yield io_1.mv(dataPath, Installer.CacheDir);
175175
// remove tmp installation to free some space
176-
yield io_1.default.rmRF(installPath);
176+
yield io_1.rmRF(installPath);
177177
return Installer.CacheDir;
178178
});
179179
}
180180
generateQdepPrf(installPath) {
181181
return __awaiter(this, void 0, void 0, function* () {
182182
// add qdep prf file
183183
const qmakePath = path_1.default.join(installPath, "bin", this._platform.qmakeName());
184-
const qdepPath = yield io_1.default.which('qdep', true);
185-
yield exec_1.default.exec(qdepPath, ["prfgen", "--qmake", qmakePath]);
186-
core_1.default.info("Successfully prepared qdep");
184+
const qdepPath = yield io_1.which('qdep', true);
185+
yield exec_1.exec(qdepPath, ["prfgen", "--qmake", qmakePath]);
186+
core_1.info("Successfully prepared qdep");
187187
});
188188
}
189189
shouldTest() {

src/installer.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os from 'os';
2-
import fs, { exists as existsCb } from 'fs';
32
import path from 'path';
3+
import { exists as existsCb } from 'fs';
44
import { URL } from 'url';
55
import { promisify } from 'util';
66

7-
import core from '@actions/core';
8-
import io from '@actions/io';
9-
import ex from '@actions/exec';
7+
import { debug, info, setOutput, addPath } from '@actions/core';
8+
import { mv, rmRF, mkdirP, which } from '@actions/io';
9+
import { exec } from '@actions/exec';
1010
import { restoreCache, saveCache } from '@actions/cache';
1111

1212
import IPlatform from './platforms/platform';
@@ -80,51 +80,51 @@ export default class Installer
8080
// try to get Qt from cache, unless clean is specified
8181
let toolPath: string | null = null;
8282
if (clean != "true") {
83-
core.debug(`Trying to restore Qt from cache with key: ${this._cacheKey} `);
83+
debug(`Trying to restore Qt from cache with key: ${this._cacheKey} `);
8484
const hitKey = await restoreCache([Installer.CacheDir], this._cacheKey);
8585
if (hitKey && await exists(path.join(Installer.CacheDir, "bin", this._platform.qmakeName()))) {
8686
toolPath = path.resolve(Installer.CacheDir);
87-
core.debug(`Restored Qt from cache to path: ${toolPath}`);
87+
debug(`Restored Qt from cache to path: ${toolPath}`);
8888
}
8989
}
9090

9191
// download, extract, cache
9292
if (!toolPath) {
93-
core.debug('Downloading and installing Qt');
93+
debug('Downloading and installing Qt');
9494
toolPath = await this.acquireQt(this.parseList(packages, ','),
9595
this.parseList(deepSrc, ' '),
9696
this.parseList(flatSrc, ' '));
97-
core.debug(`Caching Qt with key: ${this._cacheKey}`);
97+
debug(`Caching Qt with key: ${this._cacheKey}`);
9898
await this._platform.runPostInstall(false, toolPath);
9999
await saveCache([toolPath], this._cacheKey);
100100
} else
101101
await this._platform.runPostInstall(true, toolPath);
102-
core.info('Using Qt installation: ' + toolPath);
102+
info('Using Qt installation: ' + toolPath);
103103

104104
// generate qdep prf
105105
await this.generateQdepPrf(toolPath);
106106

107107
// update output / env vars
108-
core.setOutput("qtdir", toolPath);
109-
core.addPath(path.join(toolPath, "bin"));
108+
setOutput("qtdir", toolPath);
109+
addPath(path.join(toolPath, "bin"));
110110
this._platform.addExtraEnvVars(toolPath);
111111

112112
// log stuff
113-
await ex.exec("qmake", ["-version"]);
114-
await ex.exec("qmake", ["-query"]);
113+
await exec("qmake", ["-version"]);
114+
await exec("qmake", ["-query"]);
115115

116116
// set outputs
117-
core.setOutput("shell", this._platform.shellName());
118-
core.setOutput("make", this._platform.makeName());
119-
core.setOutput("tests", String(this.shouldTest()));
120-
core.setOutput("testflags", this._platform.testFlags());
117+
setOutput("shell", this._platform.shellName());
118+
setOutput("make", this._platform.makeName());
119+
setOutput("tests", String(this.shouldTest()));
120+
setOutput("testflags", this._platform.testFlags());
121121

122122
// set install dir, create artifact symlink
123123
const iPath = this._platform.installDirs(toolPath);
124-
await io.mkdirP(iPath[0]);
124+
await mkdirP(iPath[0]);
125125
const instPath = path.join(iPath[0], os.platform() == "win32" ? toolPath.substr(3) : toolPath.substr(1), "..", "..");
126-
core.setOutput('outdir', instPath);
127-
core.setOutput('installdir', iPath[1]);
126+
setOutput('outdir', instPath);
127+
setOutput('installdir', iPath[1]);
128128
}
129129

130130
private parseList(list: string, seperator: string): string[] {
@@ -153,12 +153,12 @@ export default class Installer
153153
}
154154

155155
private async installQdep(): Promise<void> {
156-
const pythonPath: string = await io.which('python', true);
157-
core.debug(`Using python: ${pythonPath}`);
158-
await ex.exec(pythonPath, ["-m", "pip", "install", "qdep"]);
159-
const qdepPath = await io.which('qdep', true);
160-
await ex.exec(qdepPath, ["--version"]);
161-
core.info("Installed qdep");
156+
const pythonPath: string = await which('python', true);
157+
debug(`Using python: ${pythonPath}`);
158+
await exec(pythonPath, ["-m", "pip", "install", "qdep"]);
159+
const qdepPath = await which('qdep', true);
160+
await exec(qdepPath, ["--version"]);
161+
info("Installed qdep");
162162
}
163163

164164
private async acquireQt(packages: string[], deepSrc: string[], flatSrc: string[]): Promise<string> {
@@ -170,7 +170,7 @@ export default class Installer
170170
await this._downloader.addSource(new URL(src), false);
171171

172172
// add packages
173-
core.debug(`Available modules: ${this._downloader.modules().join(", ")}`);
173+
debug(`Available modules: ${this._downloader.modules().join(", ")}`);
174174
for (const pkg of this._platform.extraTools())
175175
this._downloader.addDownload(pkg, true);
176176
for (const pkg of packages)
@@ -184,23 +184,23 @@ export default class Installer
184184
// move tools
185185
const oldToolPath = path.join(installPath, "Tools");
186186
if (await exists(oldToolPath))
187-
await io.mv(oldToolPath, path.join(dataPath, "Tools"));
187+
await mv(oldToolPath, path.join(dataPath, "Tools"));
188188

189189
// move out of install dir to seperate dir
190-
await io.rmRF(Installer.CacheDir);
191-
await io.mv(dataPath, Installer.CacheDir);
190+
await rmRF(Installer.CacheDir);
191+
await mv(dataPath, Installer.CacheDir);
192192

193193
// remove tmp installation to free some space
194-
await io.rmRF(installPath);
194+
await rmRF(installPath);
195195
return Installer.CacheDir;
196196
}
197197

198198
private async generateQdepPrf(installPath: string) {
199199
// add qdep prf file
200200
const qmakePath = path.join(installPath, "bin", this._platform.qmakeName());
201-
const qdepPath = await io.which('qdep', true);
202-
await ex.exec(qdepPath, ["prfgen", "--qmake", qmakePath]);
203-
core.info("Successfully prepared qdep");
201+
const qdepPath = await which('qdep', true);
202+
await exec(qdepPath, ["prfgen", "--qmake", qmakePath]);
203+
info("Successfully prepared qdep");
204204
}
205205

206206
private shouldTest(): boolean {

0 commit comments

Comments
 (0)