@puls-atlas/cli
Version:
The Puls Atlas CLI tool for managing Atlas projects
27 lines • 672 B
JavaScript
import { execSync } from 'child_process';
import logger from './logger.js';
const kebabCase = str => str.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
export default (cmd, options = {}) => {
const {
stdio = 'inherit',
cwd,
log = false,
...rest
} = options;
const command = `${cmd} ${Object.entries(rest).map(([key, value]) => {
if (value === false) {
return '';
}
if (value && value !== true) {
return `--${kebabCase(key)} ${value}`;
}
return `--${kebabCase(key)}`;
}).join(' ')}`.trim();
if (log) {
logger.debug(`Executing: ${command}`);
}
return execSync(command, {
stdio,
cwd
});
};