Jacob Brauchler Jacob Brauchler - 5 months ago 9
JSON Question

Adding a homebrew dependency to an npm package

I am wanting to add a homebrew dependency to an npm package I am trying to create, I am using drafter-HEAD. Does anyone have an ideas as to how to do this?

Answer

A couple things to come to mind. You could point the dependency to the GitHub repo if it has one.

{
  "name": "my-project-name",
  "version": "0.0.1",
  "description": "My Description Here",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "The Best Developer Ever",
  "license": "MIT",
  "dependencies": {
    "express" : "github:expressjs/express",
    "anyRepo" : "github:userName/projectName"
  }
}

you could also make a custom command in your package.json file. Call it maybe brew (this is different from the actual command line tool) and you would run your scripts there

{
  "name": "my-project-name",
  "version": "0.0.1",
  "description": "My Description Here",
  "main": "main.js",
  "scripts": {
    "brew" : "sudo brew install package-name(s)-here",
    "any-name-here" : "echo "Any command can go here"
  },
  "author": "The Best Developer Ever",
  "license": "MIT",
  "dependencies": {
    "express" : "github:expressjs/express",
  }
}

then after you would run

npm run brew

And any script inside of that command will run (aka install the homebrew dependency). This should be what you are looking for, I believe.

-- juan

EDIT ---------------------------------------------------------------------------------------------------------------------

Sorry, I accidentally gave the wrong command. You should run npm run brew NOT npm brew