Skip to content

Commit

Permalink
Introduce VALET_TARGET_OS and VALET_TARGET_ARCH
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Jun 16, 2020
1 parent 439bc16 commit 5365d42
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions release/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ const { createWriteStream, rmdirSync, mkdirSync, existsSync } = require("fs");
async function main(args) {
let start = Date.now();

/**
* @type {{
* os: "windows" | "linux" | "darwin",
* arch: "i686" | "x86_64",
* force: boolean,
* userSpecifiedOS: boolean,
* userSpecifiedArch: boolean,
* }}
*/
let opts = {
os: detectOS(),
arch: process.arch === "ia32" ? "i686" : "x86_64",
Expand All @@ -28,6 +37,34 @@ async function main(args) {
userSpecifiedArch: false,
};

{
let envOS = process.env.VALET_TARGET_OS;
if (envOS) {
if (envOS == "windows" || envOS == "linux" || envOS == "darwin") {
opts.os = envOS;
opts.userSpecifiedOS = true;
} else {
throw new Error(
"Invalid VALET_TARGET_OS=${chalk.yellow(envOS)} specified"
);
}
}
}

{
let envArch = process.env.VALET_TARGET_ARCH;
if (envArch) {
if (envArch == "i686" || envArch == "x86_64") {
opts.arch = envArch;
opts.userSpecifiedArch = true;
} else {
throw new Error(
"Invalid VALET_TARGET_ARCH=${chalk.yellow(envArch)} specified"
);
}
}
}

for (let i = 0; i < args.length; i++) {
let arg = args[i];

Expand Down

0 comments on commit 5365d42

Please sign in to comment.