Browse files

drop the "native" npm argument; compile native extensions if possible

  • Loading branch information...
1 parent b5eca5b commit 79eb634af4a658a5d76c313b08e41b00daf33f69 @einaros einaros committed Jun 14, 2012
Showing with 32 additions and 29 deletions.
  1. +6 −0 History.md
  2. +25 −28 install.js
  3. +1 −1 package.json
View
6 History.md
@@ -1,3 +1,9 @@
+v0.4.18 - June 14th 2012
+=====================
+* Fixed incorrect md5 digest encoding in Hixie handshake [nicokaiser]
+* Added example of use with Express 3 [einaros]
+* Change installation procedure to not require --ws:native to build native extensions. They will now build if a compiler is available. [einaros]
+
v0.4.17 - June 13th 2012
=====================
* Improve error handling during connection handshaking [einaros]
View
53 install.js
@@ -1,31 +1,28 @@
var spawn = require('child_process').spawn
- , exec = require('child_process').exec;
+ , exec = require('child_process').exec
+ , tinycolor = require('tinycolor')
+ , fs = require('fs')
+ , version = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8')).version
+ , verbose = process.env['npm_package_config_verbose'] != null ? process.env['npm_package_config_verbose'] === 'true' : false;
-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");
+console.log('[ws v%s]'.blue + ' Attempting to compile blazing fast native extensions.'.green, version);
- var gyp = exec('node-gyp rebuild', {cwd: __dirname});
- 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) {
- process.exit(code);
- });
-}
-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");
-}
+var gyp = exec('node-gyp rebuild', {cwd: __dirname});
+gyp.stdout.on('data', function(data) {
+ if (verbose) process.stdout.write(data);
+});
+gyp.stderr.on('data', function(data) {
+ if (verbose) process.stdout.write(data);
+});
+gyp.on('exit', function(code) {
+ if (code !== 0) {
+ console.log('[ws v%s]'.blue + ' Native extension compilation failed.'.red, version);
+ console.log('[ws v%s]'.blue + ' On Windows, native extensions require Visual Studio and Python.'.red, version);
+ console.log('[ws v%s]'.blue + ' On Unix, native extensions require Python, make and a C++ compiler.'.red, version);
+ console.log('[ws v%s]'.blue + ' Start npm with --ws:verbose to show compilation output (if any).'.red, version);
+ }
+ else {
+ console.log('[ws v%s]'.blue + ' Native extension compilation successful!'.green, version);
+ }
+ process.exit();
+});
View
2 package.json
@@ -18,7 +18,7 @@
"node": ">=0.4.0"
},
"config": {
- "native" : false
+ "verbose" : false
},
"dependencies": {
"commander": "0.5.x",

0 comments on commit 79eb634

Please sign in to comment.