Skip to content

Commit

Permalink
fix(format): Allow paths to be passed to sku format (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
jahredhope committed Aug 12, 2019
1 parent bf03730 commit 39be344
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/runPrettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const prettierConfigPath = path.join(
'../config/prettier/prettierConfig.js',
);

const runPrettier = async ({ write, listDifferent }) => {
const runPrettier = async ({ write, listDifferent, paths }) => {
console.log(
chalk.cyan(
`${write ? 'Formatting' : 'Checking'} source code with Prettier`,
Expand All @@ -38,8 +38,11 @@ const runPrettier = async ({ write, listDifferent }) => {
// don't error if `.prettierignore` not found
}

prettierArgs.push('**/*.{js,ts,tsx,md,less,css}');

if (paths && paths.length > 0) {
prettierArgs.push(...paths);
} else {
prettierArgs.push('**/*.{js,ts,tsx,md,less,css}');
}
/*
* Show Prettier output with stdio: inherit
* The child process will use the parent process's stdin/stdout/stderr
Expand Down Expand Up @@ -76,6 +79,6 @@ const runPrettier = async ({ write, listDifferent }) => {
};

module.exports = {
check: () => runPrettier({ listDifferent: true }),
write: () => runPrettier({ write: true }),
check: paths => runPrettier({ listDifferent: true, paths }),
write: paths => runPrettier({ write: true, paths }),
};

0 comments on commit 39be344

Please sign in to comment.