56 lines
1.5 KiB
TypeScript
Executable File
56 lines
1.5 KiB
TypeScript
Executable File
import fs from "fs";
|
|
import fse from "fs-extra";
|
|
import template from "lodash.template";
|
|
import os from "os";
|
|
import path from "path";
|
|
import exec from "../common/exec";
|
|
import type { Config } from "../core/config";
|
|
import { Sdk } from "../core/sdk";
|
|
|
|
export class InnoSetup extends Sdk {
|
|
static ID = "innosetup";
|
|
static VERSION = "6";
|
|
|
|
constructor(version?: string) {
|
|
super(InnoSetup.ID, version || InnoSetup.VERSION);
|
|
}
|
|
|
|
get link() {
|
|
return "http://www.jrsoftware.org/download.php/is.exe";
|
|
}
|
|
|
|
prepare(strip = 1) {
|
|
let result = super.prepare(strip);
|
|
if (!this.prepared) {
|
|
result = result.then(() => {
|
|
return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`);
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
get isccBin() {
|
|
return path.join(this.path, "ISCC.exe");
|
|
}
|
|
|
|
get prepared() {
|
|
try {
|
|
return fs.existsSync(this.isccBin);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
pack(config: Config, source: string, output: string) {
|
|
const buildDir = path.join(os.tmpdir(), "build", config.name, "innosetup");
|
|
const appTemplate = template(fs.readFileSync(path.resolve(__dirname, "..", "template/windows/app.iss"), "utf8"));
|
|
const app = appTemplate({ ...config, buildDir: buildDir, output: output });
|
|
|
|
fse.ensureDirSync(buildDir);
|
|
fse.copySync(`${source}`, `${buildDir}`);
|
|
|
|
fs.writeFileSync(path.resolve(buildDir, "app.iss"), app);
|
|
return exec(buildDir, [`"${this.isccBin}"`, "app.iss"].join(" "));
|
|
}
|
|
}
|