Permalink
Browse files

add install script which makes native extension optional

  • Loading branch information...
einaros committed Apr 30, 2012
1 parent d8d2e4c commit 43f493a27103e70f3d665a7aaac57be86427b457
Showing with 34 additions and 1 deletion.
  1. +29 −0 install.js
  2. +5 −1 package.json
View
@@ -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.

Show comment Hide comment
@TooTallNate

TooTallNate Apr 30, 2012

Contributor

probably process.exit(code) here

@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");
+}
View
@@ -11,11 +11,15 @@
"wscat": "./bin/wscat"
},
"scripts": {
- "test": "make test"
+ "test": "make test",
+ "install": "node install.js"
},
"engines": {
"node": ">=0.4.0"
},
+ "config": {
+ "native" : false
+ },
"dependencies": {
"commander": "0.5.x",
"options": "latest"

0 comments on commit 43f493a

Please sign in to comment.