Package.json 'awareness'

Apologies if this is already done easily somehow. Or if someone can point me in the vague direction of starting an Extension for this, please do!

I open a lot of random JavaScript projects at my day job. Pretty much all of them have a lot of helpful information in the package.json file, a pretty common pattern (to say the least). It seems like Nova could detect the existence of a package.json file when I first open a new folder, and do some sensible things with it:

  • Offer to help with package management (npm/yarn), maybe even with a cool sidebar
  • Create default tasks based on things in the scripts key
  • Other things I’ve thought of before, but can’t remember right now

Is this on any kind of feature roadmap? If not, it seems feasible for an extension to do this. Is there a relevant API for noticing when I’m opening a new folder?

onDidChangePath(callback, [thisValue])

I think that might be what you want (it’s part of the nova.workspace api).

You can also use nova.workspaces.contains(“package.json”) to test for presence of that file.

I don’t work a lot in JS (in fact, the most JS I’ve ever written is for the Nova extensions and Tree-sitter grammars I’ve created – I’m a systems guy and usually live in languages like C, Go, and recently D.)

There is a already an NPM tasks extension: Automatic Tasks | Nova Extensions

Making an NPM dependencies sidebar is something I’ve thought about doing. The API for the sidebar UI is pretty limited, but with some creativity it can probably be done.

Go to Extensions → Create New Extension… and choose the sidebar template to get started.

@eablokker that extension is exactly (enough) what I needed (for now)! It even lets me pick between npm and yarn. I probably could have done a better job searching for it. :slight_smile: