Skip to content

v9#1333

Merged
typicode merged 37 commits intomainfrom
experiment
Jan 25, 2024
Merged

v9#1333
typicode merged 37 commits intomainfrom
experiment

Conversation

@typicode
Copy link
Copy Markdown
Owner

No description provided.

@typicode typicode merged commit ec13855 into main Jan 25, 2024
@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
Copy Markdown

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
Copy Markdown
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.

2 participants