Skip to main content

20 posts tagged with "dev"

View All Tags

Npm Q&A

Npm is a package manager for JavaScript projects. What this means is that it enables easy installation of packages (published to the public registry, https://www.npmjs.com, or private registries) while also installing nested dependencies between packages. I received a bunch of questions about npm, and here are the answers! Note that I haven't looked at implementation details or any specs on how npm works, these answers are merely based on my observations after a decade of using npm.

Making Your Terminal Awesome

The tools we use as developers make us more effective (or at least hopefully faster) developers. So why not spend some time to make one of the most common dev tools much more useful? Here's a way to give any terminal app a personalized and awesome experience (fwiw I use the default app included with macOS). Features covered will be the following:

  • a super informative and customizable prompt
  • per-directory prompt customization
  • automatic switching of Node.js versions (easily extended to any run-time)
  • better auto complete and history
  • optional "command done" chime

Open Multiple Files in VS Code from a Grep

A simple script:

grep -rl '<search-string>' <search/dir> | xargs code -r

Between two different directories:

cd <first-path> && grep -rl '<search-string>' <search/dir> | (cd <second-path>; xargs code -r)

What's in import.meta?

If you look at the import.meta docs on MDN you'll notice that it says:

The spec doesn't specify any properties to be defined on it, but hosts usually implement the following properties: [url, resolve]

So what is actually in there? MDN is correct in saying url and resolve are usually (always) implemented, but each run-time also sticks some other stuff in there. From my own testing, below are the values that exist for each major runtime.

Unified JavaScript Testing

Node.js now has a built-in test runner, which I've now tried, and it's fantastic! However, it can't be used for frontend testing, or browser testing, obviously. While web-test-runner is the best (imo) test runner for frontend tests, having different runners requires you to learn different libraries and use different imports for each even when doing dead simple environment-agnostic unit tests. In this post I'll talk about how I've unified the experience, and the path that lead to being able to do that.