Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require("path");
- const childProcess = require("child_process");
- const prettierArgs = Array.from(process.argv).slice(2);
- const valid = [".jsx", ".js"];
- if (valid.includes(path.extname(prettierArgs[prettierArgs.length - 1]))) {
- let prettierLocation = "";
- //default locations for locally installed prettier
- if (["darwin", "linux"].includes(require("os").platform())) {
- prettierLocation = "../node_modules/.bin/prettier";
- } else {
- prettierLocation = "../node_modules/.bin/prettier.cmd";
- }
- childProcess.exec(`"${path.resolve(path.join(__dirname, prettierLocation))}" ${prettierArgs.join(" ")}`, (error, stdout, stderr) => {
- if (stderr) console.log(`${stderr}`);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement