@fredericmarx/gitignore

1.1.6 • Public • Published

@fredericmarx/gitignore

Node.js CI Node.js Package

When you think to yourself “Wouldn’t it be cool if I could just run npx @myname/gitignore instead of manually copying it over from my previous project every time” and then it’s suddenly 7pm.

Usage

npx @fredericmarx/gitignore

This will copy the contents of gitignore to a new .gitignore file in your current working directory.

This module is designed as a standalone CLI tool. You could install it in your project with npm install @fredericmarx/gitignore. I don’t know why you would want to do that, but who am I to tell you what to do with your life.

What’s in the .gitignore?

My .gitignore-template is based on an old, stripped-down version of GitHub’s Node .gitignore. If I run into any other conventions for log files or generated code, I will add them here as I encounter them. Most notably, this template ignores the dreaded .DS_Store files.

Things I learned making this

  • I could have had it so much easier by adding a shell command to my dotfiles that does the same thing.
  • The Node module ecosystem has become such a mess, especially if you’re just throwing together a project and copy stuff from tutorials that sometimes use ES Modules and sometimes CommonJS. I’m glad that in most of my frontend work a bundler will abstract these issues away.
  • If you want to make your package executable via npx, you need two things: a bin field in your package.json, and a shebang at the start of the file you want to execute.
  • I played around with git commit hooks for this one, and Husky made it super easy to work with them. They also do some clever things with npx in their installation process, so I naturally felt a deep kinship with them.
  • Node.js has a built-in test runner! It feels a bit clunky compared to fully-featured libraries like Jest, but I liked the idea of Using The Platform, and keeping external dependencies to a minimum. I initially decided to add tests as a joke to make this as overengineered as possible, but they actually saved me from a bug already when I had to significantly reshuffle my code due to the npm .gitignore bundling fiasco (see next point)
  • npm makes it incredibly hard to bundle a .gitignore file with your package. Not gonna lie, that was the one that really made me want to set my computer on fire 😫. See, the whole reason I started this project, the pièce de résistance, if you will, is that I wanted to create a JavaScript module that, upon execution, copies its own .gitignore file to your current working directory. After some back and forth I decided to choose the popular workaround of simply using a gitignore template (without the leading dot), which is pragmatic, but infinitely less fun.

Package Sidebar

Install

npm i @fredericmarx/gitignore

Weekly Downloads

1

Version

1.1.6

License

MIT

Unpacked Size

10.3 kB

Total Files

12

Last publish

Collaborators

  • fredericmarx