将自制软件依赖项添加到 npm 包

Adding a homebrew dependency to an npm package

我想将自制软件依赖项添加到我尝试创建的 npm 包中,我正在使用 drafter-HEAD。有没有人知道如何做到这一点?

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 运行 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 运行

npm run brew

And any script inside of that command will 运行 (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 运行 npm run brew NOT npm brew

您可以使用 Brewfile 指定通过 Homebrew 安装的依赖项,并使用 brew bundle 命令安装依赖项。 Brewfile 类似于您的 package.json,它是您的依赖项的清单。与在 npm 脚本中指定参数列表相比,这将更易于阅读和维护。此外,您还将获得包管理器的其他好处,例如 lockfile (Brewfile.lock.json) 的生成,尽管 Homebrew 的 lockfile 与典型的 lockfile (reference).

进一步阅读