node-talisman
Version:
A npm package for running Thoughtwork's Talisman tool
38 lines (34 loc) • 1.07 kB
JavaScript
import execSh from 'exec-sh';
import messages from "../messages.js";
import { CONSOLE_COLORS } from "../constants.js";
import logToConsole, { logToConsoleForDebugging } from "../utils/logToConsole.js";
import { isWindows } from "../utils/getOSDetails.js";
import wrapTextIfNotWindows from "../utils/wrapTextIfNotWindows.js";
const wrapTextWithQuotesIfNotWindows = wrapTextIfNotWindows(`"`);
const makeExecutable = ({
filePath
}) => {
logToConsoleForDebugging({
filePath
});
return new Promise((resolve, reject) => {
if (isWindows()) {
return resolve();
}
return execSh([`chmod +x ${wrapTextWithQuotesIfNotWindows(filePath)}`], error => {
if (!error) {
logToConsole({
color: CONSOLE_COLORS.green
}, messages.makeExecutable.succeed.toString());
logToConsole();
return resolve();
}
logToConsole({
color: CONSOLE_COLORS.red
}, messages.makeExecutable.failed.toString());
logToConsole();
return reject(error);
});
});
};
export default makeExecutable;