Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-03-07 07:48:22 +0400
committerisaacs <i@izs.me>2012-03-13 02:04:36 +0400
commit66db8b243991b71bd1ee2f12d049595deaa8bfea (patch)
tree4caf9334c3b1311c9e3300b7119704a4dd8b1335
parentc4eb2fd8e22dea7f92424c16ddcec2ec992a2465 (diff)
Automatically node-gyp build stuff with a bindings.gyp
-rw-r--r--lib/utils/read-json.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js
index 8fdd60f66..ceeebdf27 100644
--- a/lib/utils/read-json.js
+++ b/lib/utils/read-json.js
@@ -34,6 +34,18 @@ function readJson (jsonFile, opts, cb) {
var wscript = null
, contributors = null
, serverjs = null
+ , gypfile = null
+
+ if (options.gypfile !== null && opts.gypfile !== undefined) {
+ gypfile = opts.gypfile
+ next()
+ } else {
+ fs.readFile( path.join(path.dirname(jsonFile), "bindings.gyp")
+ , function (er, data) {
+ opts.gypfile = !er
+ next()
+ })
+ }
if (opts.wscript !== null && opts.wscript !== undefined) {
wscript = opts.wscript
@@ -76,9 +88,10 @@ function readJson (jsonFile, opts, cb) {
})
function next () {
- if (wscript === null
- || contributors === null
- || serverjs === null) {
+ if (wscript === null ||
+ contributors === null ||
+ gypfile === null ||
+ serverjs === null) {
return
}
@@ -332,6 +345,15 @@ function processObject (opts, cb) { return function (er, json) {
var scripts = json.scripts || {}
+ // if it has a bindings.gyp, then build with node-gyp
+ if (opts.gypfile && !json.prebuilt) {
+ log.verbose([json.prebuilt, opts], "has bindings.gyp")
+ if (!scripts.install && !scripts.preinstall) {
+ scripts.preinstall = "node-gyp clean || (exit 0); node-gyp configure ; node-gyp build"
+ json.scripts = scripts
+ }
+ }
+
// if it has a wscript, then build it.
if (opts.wscript && !json.prebuilt) {
log.verbose([json.prebuilt, opts], "has wscript")