nwixtoolset
Version:
Node module wrapper around the WIX Toolset executables.
79 lines (78 loc) • 2.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const child_process_1 = require("child_process");
const util_1 = require("./util");
/**
* Run given WIX executable by using raw arguments.
*
* @param exe The WIX executable to run.
* @param args The arguments to pass to bundler.
* @param [options] The options for child_process.spawn.
*/
function run(exe, args, options = {}) {
return new Promise((resolve, reject) => {
let cmd = path.resolve(__dirname, "..", "wix-bin", `${exe}.exe`);
if (util_1.isWineEnv()) {
args.unshift(cmd);
cmd = "wine";
}
const childOptions = {};
if (!util_1.undef(options.cwd))
childOptions.cwd = options.cwd;
if (!util_1.undef(options.stdio))
childOptions.stdio = options.stdio;
const child = child_process_1.spawn(cmd, args, childOptions);
let stdout = "", stderr = "";
if (options.stdio !== "ignore" && options.stdio !== "inherit") {
child.stdout.on("data", data => { stdout += String(data); });
child.stderr.on("data", data => { stderr += String(data); });
}
child.on("error", reject);
child.on("close", code => {
if (code === 0) {
return resolve({ code, stdout, stderr });
}
const err = new Error(`WIX ${exe} exited with code ${code}` + (stderr ? `\n${stderr}` : ""));
err.command = cmd;
err.args = args;
err.code = code;
err.stdout = stdout;
err.stderr = stderr;
reject(err);
});
});
}
exports.run = run;
/** Collections of RAW wrappers. */
var raw;
(function (raw) {
/** Raw wrapper for the candle.exe. */
raw.candle = run.bind(null, "candle");
/** Raw wrapper for the dark.exe. */
raw.dark = run.bind(null, "dark");
/** Raw wrapper for the heat.exe. */
raw.heat = run.bind(null, "heat");
/** Raw wrapper for the insignia.exe. */
raw.insignia = run.bind(null, "insignia");
/** Raw wrapper for the light.exe. */
raw.light = run.bind(null, "light");
/** Raw wrapper for the lit.exe. */
raw.lit = run.bind(null, "lit");
/** Raw wrapper for the lux.exe. */
raw.lux = run.bind(null, "lux");
/** Raw wrapper for the melt.exe. */
raw.melt = run.bind(null, "melt");
/** Raw wrapper for the nit.exe. */
raw.nit = run.bind(null, "nit");
/** Raw wrapper for the pyro.exe. */
raw.pyro = run.bind(null, "pyro");
/** Raw wrapper for the retina.exe. */
raw.retina = run.bind(null, "retina");
/** Raw wrapper for the shine.exe. */
raw.shine = run.bind(null, "shine");
/** Raw wrapper for the smoke.exe. */
raw.smoke = run.bind(null, "smoke");
/** Raw wrapper for the torch.exe. */
raw.torch = run.bind(null, "torch");
})(raw = exports.raw || (exports.raw = {}));