node-talisman
Version:
A npm package for running Thoughtwork's Talisman tool
33 lines (30 loc) • 913 B
JavaScript
import path from 'path';
import { CHECKSUMS, PATHS, META_INFO } from "../constants.js";
import { isWindows, getPlatform, getArchitecture } from "../utils/getOSDetails.js";
import doesFileExists from "../utils/doesFileExists.js";
import install from "./install.js";
import check from "./check.js";
const fileName = `talisman_${getPlatform()}_${getArchitecture()}${isWindows() ? '.exe' : ''}`;
const url = `https://github.com/thoughtworks/talisman/releases/download/${META_INFO.version}/${fileName}`;
const checksum = CHECKSUMS[fileName];
const fileBasePath = PATHS.BINARY;
const filePath = path.resolve(fileBasePath, fileName);
const runner = args => {
if (doesFileExists(filePath)) {
return check({
filePath,
args
});
}
return install({
url,
checksum,
fileBasePath,
fileName,
filePath
}).then(() => check({
filePath,
args
}));
};
export default runner;