-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dkonchekov's file list cli params #9
base: master
Are you sure you want to change the base?
Conversation
@dkonchekov I hope it's OK that I put this PR together, I couldn't figure out how to ask you first 😅 |
`file://${file}`, | ||
"vue", | ||
0, | ||
fs.readFileSync(file, "utf8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be better to read the file asynchronously:
fs.readFileSync(file, "utf8") | |
await fs.readFile(file, "utf8") |
Also, this block should better be extracted to an async function enumerate
, just like traverse
.
const cwd = process.cwd(); | ||
|
||
check({ | ||
workspace: path.resolve(cwd, workspace), | ||
workspace: path.resolve(cwd, workspace || "."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be possible to reuse cwd
for this?
workspace: path.resolve(cwd, workspace || "."), | |
workspace: path.resolve(cwd, workspace || cwd), |
It would be more readable to keep the !workspace
block, but move it after the cwd
assignment:
const cwd = process.cwd();
if (!workspace) {
workspace = cwd;
}
@@ -8,6 +8,7 @@ | |||
"vtc": "dist/cli.js" | |||
}, | |||
"scripts": { | |||
"prepare": "npm run compile", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that really necessary?
This PR adds dkonchekov's changes to support specifying the files to be checked, instead of the whole folder.
This is especially useful for pre-commit hooks, where you don't want all of the files checked, just those that have changed.
For those looking to set up their own pre-commit hooks, here's what I added to my package.json: