Skip to content

Commit

Permalink
add install script which makes native extension optional
Browse files Browse the repository at this point in the history
  • Loading branch information
einaros committed Apr 30, 2012
1 parent d8d2e4c commit 43f493a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
29 changes: 29 additions & 0 deletions install.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,29 @@
var spawn = require('child_process').spawn
, exec = require('child_process').exec;

var build_native = process.env['npm_package_config_native'] != null ? process.env['npm_package_config_native'] : 'false';
build_native = build_native == 'true' ? true : false;
if(build_native) {
process.stdout.write("================================================================================\n");
process.stdout.write("= =\n");
process.stdout.write("= Building WS with blazing fast native extensions. =\n");
process.stdout.write("= =\n");
process.stdout.write("================================================================================\n");

var gyp = spawn('node-gyp', ['rebuild']);
gyp.stdout.on('data', function(data) {
process.stdout.write(data);
});
gyp.stderr.on('data', function(data) {
process.stdout.write(data);
});
gyp.on('exit', function(code) {});

This comment has been minimized.

Copy link
@TooTallNate

TooTallNate Apr 30, 2012

Contributor

probably process.exit(code) here

}
else {
process.stdout.write("================================================================================\n");
process.stdout.write("= =\n");
process.stdout.write("= To install WS with blazing fast native extensions, use =\n");
process.stdout.write("= <npm install ws --ws:native> =\n");
process.stdout.write("= =\n");
process.stdout.write("================================================================================\n");
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
"wscat": "./bin/wscat" "wscat": "./bin/wscat"
}, },
"scripts": { "scripts": {
"test": "make test" "test": "make test",
"install": "node install.js"
}, },
"engines": { "engines": {
"node": ">=0.4.0" "node": ">=0.4.0"
}, },
"config": {
"native" : false
},
"dependencies": { "dependencies": {
"commander": "0.5.x", "commander": "0.5.x",
"options": "latest" "options": "latest"
Expand Down

0 comments on commit 43f493a

Please sign in to comment.