Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

v9 #1333

Merged
merged 37 commits into from
Jan 25, 2024
Merged

v9 #1333

merged 37 commits into from
Jan 25, 2024

Conversation

typicode
Copy link
Owner

No description provided.

@typicode typicode merged commit ec13855 into main Jan 25, 2024
6 checks passed
@typicode typicode deleted the experiment branch January 25, 2024 01:49
Comment on lines +1 to +21
#!/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))
Copy link

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!

Copy link
Owner Author

@typicode typicode Apr 27, 2024

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants