|
1 | | -var download = require('./download').download; |
2 | | -var spawn = require('child_process').spawn; |
3 | | -var path = require('path'); |
4 | | -var fs = require('fs'); |
| 1 | +var download = require("./download").download; |
| 2 | +var spawn = require("child_process").spawn; |
| 3 | +var path = require("path"); |
| 4 | +var fs = require("fs"); |
5 | 5 |
|
6 | 6 | var ZMQ; |
7 | 7 | var ZMQ_REPO; |
8 | | -if (process.platform == 'linux') { |
9 | | - ZMQ = '4.1.6'; |
10 | | - ZMQ_REPO = 'zeromq4-1'; |
| 8 | +if (process.platform == "linux") { |
| 9 | + ZMQ = "4.1.6"; |
| 10 | + ZMQ_REPO = "zeromq4-1"; |
11 | 11 | } else { |
12 | | - ZMQ = '4.2.0'; |
13 | | - ZMQ_REPO = 'libzmq'; |
| 12 | + ZMQ = "4.2.0"; |
| 13 | + ZMQ_REPO = "libzmq"; |
14 | 14 | } |
15 | 15 |
|
16 | 16 | function buildZMQ(scriptPath, zmqDir) { |
17 | | - console.log('Building libzmq for ' + process.platform); |
| 17 | + console.log("Building libzmq for " + process.platform); |
18 | 18 |
|
19 | 19 | var child = spawn(scriptPath, [ZMQ]); |
20 | 20 |
|
21 | 21 | child.stdout.pipe(process.stdout); |
22 | 22 | child.stderr.pipe(process.stderr); |
23 | | - child.on('error', function(err) { |
24 | | - console.error('Failed to start child process.'); |
| 23 | + child.on("error", function(err) { |
| 24 | + console.error("Failed to start child process."); |
25 | 25 | }); |
26 | | - child.on('close', function(code) { |
| 26 | + child.on("close", function(code) { |
27 | 27 | if (code !== 0) { |
28 | | - return console.error('child process exited with code ' + code); |
| 28 | + return console.error("child process exited with code " + code); |
29 | 29 | } |
30 | | - var message = 'Succesfully build libzmq on ' + Date(); |
31 | | - fs.writeFile(path.join(zmqDir, 'BUILD_SUCCESS'), message, function(err) { |
| 30 | + var message = "Succesfully build libzmq on " + Date(); |
| 31 | + fs.writeFile(path.join(zmqDir, "BUILD_SUCCESS"), message, function(err) { |
32 | 32 | if (err) { |
33 | 33 | return console.error(err.message); |
34 | 34 | } |
35 | 35 | console.log(message); |
36 | 36 | }); |
37 | | -}); |
| 37 | + }); |
38 | 38 | } |
39 | 39 |
|
40 | | -if (process.platform === 'win32') { |
41 | | - var LIB_URL = 'https://github.com/nteract/libzmq-win/releases/download/v2.0.0/libzmq-' + ZMQ + '-' + process.arch + '.lib'; |
42 | | - var DIR_NAME = path.join(__dirname, '..', 'windows', 'lib'); |
43 | | - var FILE_NAME = path.join(DIR_NAME, 'libzmq.lib'); |
| 40 | +if (process.platform === "win32") { |
| 41 | + var LIB_URL = |
| 42 | + "https://github.com/nteract/libzmq-win/releases/download/v2.0.0/libzmq-" + |
| 43 | + ZMQ + |
| 44 | + "-" + |
| 45 | + process.arch + |
| 46 | + ".lib"; |
| 47 | + var DIR_NAME = path.join(__dirname, "..", "windows", "lib"); |
| 48 | + var FILE_NAME = path.join(DIR_NAME, "libzmq.lib"); |
44 | 49 |
|
45 | 50 | if (!fs.existsSync(DIR_NAME)) { |
46 | 51 | fs.mkdirSync(DIR_NAME); |
47 | 52 | } |
48 | 53 |
|
49 | 54 | if (!fs.existsSync(FILE_NAME)) { |
50 | | - console.log('Downloading libzmq for Windows'); |
| 55 | + console.log("Downloading libzmq for Windows"); |
51 | 56 | download(LIB_URL, FILE_NAME, function() { |
52 | | - console.log('Download finished'); |
| 57 | + console.log("Download finished"); |
53 | 58 | }); |
54 | 59 | } |
55 | | - |
56 | 60 | } else { |
57 | | - var SCRIPT_PATH = path.join(__dirname, 'build_libzmq.sh'); |
58 | | - var TAR_URL = 'https://github.com/zeromq/' + ZMQ_REPO + '/releases/download/v' + ZMQ + '/zeromq-' + ZMQ + '.tar.gz'; |
59 | | - var DIR_NAME = path.join(__dirname, '..', 'zmq'); |
60 | | - var FILE_NAME = path.join(DIR_NAME, 'zeromq-' + ZMQ + '.tar.gz'); |
| 61 | + var SCRIPT_PATH = path.join(__dirname, "build_libzmq.sh"); |
| 62 | + var TAR_URL = |
| 63 | + "https://github.com/zeromq/" + |
| 64 | + ZMQ_REPO + |
| 65 | + "/releases/download/v" + |
| 66 | + ZMQ + |
| 67 | + "/zeromq-" + |
| 68 | + ZMQ + |
| 69 | + ".tar.gz"; |
| 70 | + var DIR_NAME = path.join(__dirname, "..", "zmq"); |
| 71 | + var FILE_NAME = path.join(DIR_NAME, "zeromq-" + ZMQ + ".tar.gz"); |
61 | 72 |
|
62 | 73 | if (!fs.existsSync(DIR_NAME)) { |
63 | 74 | fs.mkdirSync(DIR_NAME); |
64 | 75 | } |
65 | 76 |
|
66 | | - if (fs.existsSync(path.join(DIR_NAME, 'BUILD_SUCCESS'))) { |
67 | | - return console.log('Libzmq found, skipping rebuild.'); |
| 77 | + if (fs.existsSync(path.join(DIR_NAME, "BUILD_SUCCESS"))) { |
| 78 | + console.log("Libzmq found, skipping rebuild."); |
| 79 | + process.exit(0); |
68 | 80 | } |
69 | 81 |
|
70 | 82 | if (fs.existsSync(FILE_NAME)) { |
71 | | - return buildZMQ(SCRIPT_PATH, DIR_NAME); |
| 83 | + buildZMQ(SCRIPT_PATH, DIR_NAME); |
| 84 | + process.exit(0); |
72 | 85 | } |
73 | 86 |
|
74 | 87 | download(TAR_URL, FILE_NAME, function() { |
75 | 88 | buildZMQ(SCRIPT_PATH, DIR_NAME); |
76 | 89 | }); |
77 | | - |
78 | 90 | } |
0 commit comments