@@ -3,26 +3,49 @@ var spawn = require('child_process').spawn;
33var path = require ( 'path' ) ;
44var fs = require ( 'fs' ) ;
55
6- if ( process . platform === 'win32' ) {
7- console . log ( 'Downloading libzmq for Windows' )
6+ var ZMQ = '4.2.0' ;
7+
8+ function buildZMQ ( scriptPath ) {
9+ console . log ( 'Building libzmq for ' + process . platform )
10+
11+ var child = spawn ( scriptPath , [ ZMQ ] ) ;
12+
13+ child . stdout . pipe ( process . stdout ) ;
14+ child . stderr . pipe ( process . stderr ) ;
15+ child . on ( 'error' , ( err ) => {
16+ console . error ( 'Failed to start child process.' ) ;
17+ } ) ;
18+ }
819
9- var TAR_URL = 'https://github.com/nteract/libzmq-win/releases/download/v1.0.0/libzmq-' + process . arch + '.lib' ;
20+ if ( process . platform === 'win32' ) {
21+ var LIB_URL = 'https://github.com/nteract/libzmq-win/releases/download/v2.0.0/libzmq-' + ZMQ + '-' + process . arch + '.lib' ;
1022 var DIR_NAME = path . join ( __dirname , '..' , 'windows' , 'lib' ) ;
1123 var FILE_NAME = path . join ( DIR_NAME , 'libzmq.lib' ) ;
1224
1325 if ( ! fs . existsSync ( DIR_NAME ) ) {
1426 fs . mkdirSync ( DIR_NAME ) ;
1527 }
1628
17- download ( TAR_URL , FILE_NAME ) ;
29+ if ( ! fs . existsSync ( FILE_NAME ) ) {
30+ console . log ( 'Downloading libzmq for Windows' ) ;
31+ download ( LIB_URL , FILE_NAME , function ( ) {
32+ console . log ( 'Download finished' ) ;
33+ } ) ;
34+ }
35+
1836} else {
19- console . log ( 'Building libzmq for ' + process . platform )
37+ var SCRIPT_PATH = path . join ( __dirname , 'build_libzmq.sh' ) ;
38+ var TAR_URL = 'https://github.com/zeromq/libzmq/releases/download/v' + ZMQ + '/zeromq-' + ZMQ + '.tar.gz' ;
39+ var DIR = path . join ( __dirname , '..' , 'zmq' ) ;
40+ var FILE_NAME = path . join ( DIR , 'zeromq-' + ZMQ + '.tar.gz' ) ;
2041
21- var child = spawn ( './scripts/build_libzmq.sh' ) ;
42+ if ( ! fs . existsSync ( DIR ) ) {
43+ fs . mkdirSync ( DIR ) ;
44+ }
2245
23- child . stdout . pipe ( process . stdout ) ;
24- child . stderr . pipe ( process . stderr ) ;
25- child . on ( 'error' , ( err ) => {
26- console . error ( 'Failed to start child process.' ) ;
27- } ) ;
46+ if ( fs . existsSync ( FILE_NAME ) ) {
47+ buildZMQ ( SCRIPT_PATH ) ;
48+ } else {
49+ download ( TAR_URL , FILE_NAME , function ( ) { buildZMQ ( SCRIPT_PATH ) ; } ) ;
50+ }
2851}
0 commit comments