https://github.com/jcoreio/promake-node-modules
promake recipe for installing node_modules only when necessary
https://github.com/jcoreio/promake-node-modules
promake yarn
Last synced: about 2 months ago
JSON representation
promake recipe for installing node_modules only when necessary
- Host: GitHub
- URL: https://github.com/jcoreio/promake-node-modules
- Owner: jcoreio
- License: mit
- Created: 2018-06-09T19:04:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:59:58.000Z (over 3 years ago)
- Last Synced: 2025-10-22T08:35:46.288Z (8 months ago)
- Topics: promake, yarn
- Language: JavaScript
- Size: 3.25 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# promake-node-modules
[](https://circleci.com/gh/jcoreio/promake-yarn)
[](https://codecov.io/gh/jcoreio/promake-yarn)
[](https://github.com/semantic-release/semantic-release)
[](http://commitizen.github.io/cz-cli/)
[](https://badge.fury.io/js/promake-yarn)
Promake rule for installing node_modules only when necessary. It also prevents install processes from running
simultaneously, since that's easy to do accidentally when some targets depend on a node_modules rule.
# Usage
```
npm install --save promake-node-modules
```
## Example in Promake script
```js
#!/usr/bin/env node
// @flow
const Promake = require('promake')
const fs = require('fs-extra')
const nodeModulesRule = require('promake-node-modules')
const promake = new Promake()
const rule = nodeModulesRule({
promake,
projectDir: 'path/to/project', // defaults to process.cwd(),
command: 'yarn', // defaults to npm
})
promake.task('deps', [rule])
promake.cli()
```
## `nodeModulesRule(options)`
Creates a promake `HashRule` for installing `node_modules`. The hash is stored in `node_modules/.cache/promake-node-modules.md5`.
### Arguments
#### `options.promake` (`Promake`, **required**)
The instance of `Promake` to add the rule to.
#### `options.projectDir` (`string`, _optional_, default: `process.cwd()`)
The path to the project directory to install `node_modules` in.
#### `options.command` (`string`, _optional_, default: `'npm'`)
The command to run to install `node_modules`.
#### `options.args` (`string[]`, _optional_, default: `['install']`)
The arguments for the install `command`.
#### `options.install` (`(options: {rule: Rule, projectDir: string}) => Promise`)
Custom function to perform installation (overrides `command` and `args`)
#### `options.additionalFiles` (`string[]`, _optional_)
Additional files to include in the hash. You can put lockfiles in here, but be aware that
if you run a command that updates the lockfile, it will cause this rule to run again (since
the previous hash won't match).