Skip to content

Commit c198c30

Browse files
rgbkrklgeiger
authored andcommitted
run prettier on preinstall, fix errant return
1 parent 720ff56 commit c198c30

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

scripts/preinstall.js

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,90 @@
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");
55

66
var ZMQ;
77
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";
1111
} else {
12-
ZMQ = '4.2.0';
13-
ZMQ_REPO = 'libzmq';
12+
ZMQ = "4.2.0";
13+
ZMQ_REPO = "libzmq";
1414
}
1515

1616
function buildZMQ(scriptPath, zmqDir) {
17-
console.log('Building libzmq for ' + process.platform);
17+
console.log("Building libzmq for " + process.platform);
1818

1919
var child = spawn(scriptPath, [ZMQ]);
2020

2121
child.stdout.pipe(process.stdout);
2222
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.");
2525
});
26-
child.on('close', function(code) {
26+
child.on("close", function(code) {
2727
if (code !== 0) {
28-
return console.error('child process exited with code ' + code);
28+
return console.error("child process exited with code " + code);
2929
}
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) {
3232
if (err) {
3333
return console.error(err.message);
3434
}
3535
console.log(message);
3636
});
37-
});
37+
});
3838
}
3939

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");
4449

4550
if (!fs.existsSync(DIR_NAME)) {
4651
fs.mkdirSync(DIR_NAME);
4752
}
4853

4954
if (!fs.existsSync(FILE_NAME)) {
50-
console.log('Downloading libzmq for Windows');
55+
console.log("Downloading libzmq for Windows");
5156
download(LIB_URL, FILE_NAME, function() {
52-
console.log('Download finished');
57+
console.log("Download finished");
5358
});
5459
}
55-
5660
} 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");
6172

6273
if (!fs.existsSync(DIR_NAME)) {
6374
fs.mkdirSync(DIR_NAME);
6475
}
6576

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);
6880
}
6981

7082
if (fs.existsSync(FILE_NAME)) {
71-
return buildZMQ(SCRIPT_PATH, DIR_NAME);
83+
buildZMQ(SCRIPT_PATH, DIR_NAME);
84+
process.exit(0);
7285
}
7386

7487
download(TAR_URL, FILE_NAME, function() {
7588
buildZMQ(SCRIPT_PATH, DIR_NAME);
7689
});
77-
7890
}

0 commit comments

Comments
 (0)