-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
v9 #1333
v9 #1333
Conversation
#!/usr/bin/env node | ||
import f, { writeFileSync as w } from 'fs' | ||
import i from './index.js' | ||
|
||
let a = process.argv[2] | ||
|
||
if (a == 'init') { | ||
let p = process.env.npm_package_json | ||
let d = JSON.parse(f.readFileSync(p)) | ||
d.scripts.prepare = 'husky' | ||
w('package.json', JSON.stringify(d, null, /\t/.test() ? '\t' : 2)) | ||
process.stdout.write(i()) | ||
w('.husky/pre-commit', process.env.npm_config_user_agent.split('/')[0] + ' test') | ||
process.exit() | ||
} | ||
|
||
let d = c => console.error(`${c} command is deprecated`) | ||
if (['add', 'set', 'uninstall'].includes(a)) { d(a); process.exit(1) } | ||
if (a == 'install') d(a) | ||
|
||
process.stdout.write(i(a == 'install' ? undefined : a)) |
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.
I am curious, what guided you to go so far with reducing the package size? Isn't keeping the code readable more valuable than reducing the already small size?
Thanks for your work tho!
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.
Good question and the answer is: it depends.
Personally, I did it for fun (it's important sometimes) and for some people, size is an important metric.
Isn't keeping the code readable more valuable than reducing the already small size?
I agree, that's why I'm not doing this for any other projects that I maintain. But here, husky is quite simple so I felt it would be manageable.
Also, I found out some positive things:
- maintenance got a lot easier without TS, Prettier and ESLint dependencies. I like this simplicity.
- I don't have to build the project to publish it.
- it forces me to focus on core value and avoid feature creep.
- I feel that it's easier to understand at a glance what each line does. In particular, if you compared to multi-lines if/else (but I'm biased since I wrote it)... also all the code fits on one screen, no scrolling necessary.
Once again, I wouldn't do it for another project but here I'm satisfied with the end result.
Thanks for your work tho!
Thanks for the kind words :)
No description provided.