UNPKG

@kadconsulting/dry

Version:
35 lines (34 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const fs = require("fs"); const format = (path) => { return new Promise((resolve, reject) => { if (fs.existsSync(path)) { /** Format SCSS with Prettier */ (0, child_process_1.exec)(`prettier --write ./${path}`, (error, _stdout, stderr) => { if (error) { console.warn(error); } if (stderr) { return reject(`An error occurred while formatting SCSS: ${stderr}`); } resolve('All SCSS files are formatted!!!'); }); /** Format all other files with Rome */ (0, child_process_1.exec)(`rome format ./${path}/*.{tsx,ts} --write`, (error, _stdout, stderr) => { if (error) { console.warn(error); } if (stderr) { return reject(`An error occurred: ${stderr}`); } resolve('All Component files are formatted!!!'); }); } else { resolve('Component Does Not Exist'); } }); }; exports.default = format;