Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Jan 14, 2025
1 parent 6d1f670 commit 98a19ab
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const tar = require('tar');
const fs = require('fs');
const os = require('os');

const dstdir = process.env.INPUT_BINDIR || '/usr/local/bin';

function platform_key() {
const platform = os.platform(); // 'darwin', 'linux', 'win32', etc.
let arch = os.arch(); // 'x64', 'arm64', etc.
Expand Down Expand Up @@ -71,7 +73,6 @@ function parse_pkgx_output(output) {
}

async function install_pkgx() {
const dstdir = process.env.INPUT_BINDIR || '/usr/local/bin';
let url = `https://dist.pkgx.dev/pkgx.sh/${platform_key()}/versions.txt`;

console.log(`::group::installing ${dstdir}/pkgx`);
Expand Down Expand Up @@ -105,8 +106,6 @@ async function install_pkgx() {
}

(async () => {
console.error(process.env);

await install_pkgx();

if (process.env.INPUT_PKGX_DIR) {
Expand All @@ -116,11 +115,11 @@ async function install_pkgx() {
if (process.env['INPUT_+']) {
console.log(`::group::installing pkgx input packages`);
const args = process.env['INPUT_+'].split(' ');
const cmd = `/usr/local/bin/pkgx ${args.map(x => `+${x}`).join(' ')}`;
const cmd = `${dstdir}/pkgx ${args.map(x => `+${x}`).join(' ')}`;
console.log(`running: \`${cmd}\``);
let env = {}
let env = undefined;
if (process.env.INPUT_PKGX_DIR) {
env.PKGX_DIR = process.env.INPUT_PKGX_DIR;
env = {PKGX_DIR: process.env.INPUT_PKGX_DIR};
}
const output = execSync(cmd, {env});
parse_pkgx_output(output.toString());
Expand All @@ -133,4 +132,7 @@ async function install_pkgx() {
execSync(installer_script_path, {env: {PKGX_UPDATE: 'no'}});
console.log(`::endgroup::`);
}
})().catch(err => console.error(`::error::${err.message}`));
})().catch(err => {
console.error(`::error::${err.message}`)
process.exit(1);
});

0 comments on commit 98a19ab

Please sign in to comment.