https://github.com/junosuarez/node-npm-idempotent-rebuild
node module: run npm rebuild only if cannot load native modules
https://github.com/junosuarez/node-npm-idempotent-rebuild
Last synced: 9 months ago
JSON representation
node module: run npm rebuild only if cannot load native modules
- Host: GitHub
- URL: https://github.com/junosuarez/node-npm-idempotent-rebuild
- Owner: junosuarez
- License: isc
- Created: 2016-03-02T09:54:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-28T06:01:54.000Z (about 10 years ago)
- Last Synced: 2025-02-15T16:46:20.137Z (over 1 year ago)
- Language: JavaScript
- Size: 200 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# npm-idempotent-rebuild
run npm rebuild only if cannot load native modules
[][npm]
[][standard]
[][dependencies]
[][circleci]
[npm]: https://www.npmjs.com/package/npm-idempotent-rebuild
[standard]: http://standardjs.com/
[dependencies]: https://david-dm.org/jden/node-npm-idempotent-rebuild
[circleci]: https://circleci.com/gh/jden/node-npm-idempotent-rebuild
Rebuilding native modules can be slow. This module attempts loading all native modules in
the dependency tree. If they fail, it runs `npm rebuild`. This is useful when switching
between node versions or between operating systems with cached `node_modules` directories.
## cli usage
```
$ npm-idempotent-rebuild
```
## programmatic usage
```js
const npmIdempotentRebuild = require('npm-idempotent-rebuild')
npmIdempotentRebuild({dir: __dirname}, function (err, rebuilt) {
console.log(err, rebuilt ? : 'rebuilt node modules' : 'skipped rebuilding')
})
```
## api
with [jsig](https://github.com/jsigbiz/spec) type annotation:
### `npmIdempotentRebuild(opt, callback : Callback) => void`
Rebuilds node_modules if necessary. Takes a Node.js-style callback with error, if any,
and `rebuilt`, which is true if `npm rebuild` was executed.
Options:
- `level`: String - one of `silent` (default), `info`, or `debug`
- `dir`: String - the cwd for running `npm rebuild`, defaults to current cwd.
## installation
$ npm install npm-idempotent-rebuild
## running the tests
From package root:
$ npm install
$ npm test
For debug information, set env var DEBUG=true
## contributors
- jden
## license
ISC. (c) MMXVI jden . See LICENSE.md