shellcheck
Version:
Wrapper to download shellcheck
20 lines (19 loc) • 706 B
JavaScript
import process from 'node:process';
import { config } from "../configs/index.js";
import { ArchitectureError } from "../errors/index.js";
/**
* Convert architecture to ShellCheck architecture.
*
* @param args - Arguments.
* @returns ShellCheck architecture.
*/
export function shellCheckArchitecture(args) {
const opts = {
architecture: args?.architecture ?? process.arch,
platform: args?.platform ?? process.platform,
};
const architecture = config.binaries[opts.platform]?.architectures.find(arch => arch[0] === opts.architecture)?.[1];
if (architecture === undefined)
throw new ArchitectureError(opts.architecture, opts.platform);
return architecture;
}