Skip to content

Commit fe7124f

Browse files
committedFeb 4, 2021
Merge branch 'get-rid-of-lodash' of https://github.com/lydell/binwrap into release/2.3.0
2 parents a41e725 + cee0b45 commit fe7124f

6 files changed

+67
-97
lines changed
 

‎.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ node_js:
33
- "8"
44
- "10"
55
- "12"
6-
7-
before_script:
8-
- (cd test_app && npm install ../)

‎binstub.js.mustache ‎binstub.js.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (os == "win32") {
1818
}
1919

2020
var unpackedBinPath = path.join(__dirname, "..", "unpacked_bin");
21-
var binPath = path.join(unpackedBinPath, "{{ binName }}" + binExt);
21+
var binPath = path.join(unpackedBinPath, $binName$ + binExt);
2222

2323
function execBin() {
2424
spawn(

‎package-lock.json

+44-62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Package cross-platform binaries",
55
"main": "index.js",
66
"scripts": {
7-
"test": "(cd test_app && ./build_packages.sh) && mocha && eslint ."
7+
"test": "(cd test_app && ./build_packages.sh && npm install ../) && mocha && eslint ."
88
},
99
"repository": {
1010
"type": "git",
@@ -21,7 +21,7 @@
2121
"prepare.js",
2222
"test.js",
2323
"binstall.js",
24-
"binstub.js.mustache",
24+
"binstub.js.template",
2525
"bin/binwrap-install",
2626
"bin/binwrap-prepare",
2727
"bin/binwrap-test"
@@ -39,9 +39,7 @@
3939
"mocha": "^8.2.1"
4040
},
4141
"dependencies": {
42-
"mustache": "^4.1.0",
4342
"request": "^2.88.0",
44-
"request-promise": "^4.2.5",
4543
"tar": "^6.1.0",
4644
"unzip-stream": "^0.3.1"
4745
}

‎prepare.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
var fs = require("fs");
22
var path = require("path");
3-
var mustache = require("mustache");
43

54
module.exports = function prepare(config) {
65
if (!fs.existsSync("bin")) {
76
fs.mkdirSync("bin");
87
}
98

10-
var binstubTemplate = fs.readFileSync(path.join(__dirname, "binstub.js.mustache")).toString();
9+
var binstubTemplate = fs.readFileSync(path.join(__dirname, "binstub.js.template")).toString();
1110

1211
config.binaries.forEach(function(bin) {
1312
var binPath = path.join("bin", bin);
14-
var content = mustache.render(binstubTemplate, { binName: bin });
13+
var content = binstubTemplate.replace(/\$binName\$/g, JSON.stringify(bin));
1514
fs.writeFileSync(binPath, content);
1615
fs.chmodSync(binPath, "755");
1716
});

‎test.js

+18-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var request = require("request-promise");
1+
var request = require("request");
22

33
// https://nodejs.org/api/os.html#os_os_platform
44
var validPlatforms = {
@@ -29,7 +29,6 @@ var validArchs = {
2929

3030
module.exports = function test(config) {
3131
var errors = [];
32-
var checkedUrls = {};
3332

3433
var chain = Object.keys(config.urls).reduce(
3534
function(p, buildId) {
@@ -49,30 +48,25 @@ module.exports = function test(config) {
4948
if (url.slice(0,5) === "http:") {
5049
console.log("WARNING: Binary is published at an insecure URL (using https is recommended): " + displayUrl)
5150
}
52-
if (checkedUrls[url]) {
53-
return p.then(function() {
54-
console.log("OKAY: " + displayUrl);
55-
});
56-
} else {
57-
return p.then(function() {
58-
return request({
59-
method: "GET",
60-
uri: url,
61-
resolveWithFullResponse: true
62-
})
63-
.then(function(response) {
64-
if (response.statusCode != 200) {
65-
throw new Error("Status code " + response.statusCode);
66-
} else {
67-
console.log("OKAY: " + displayUrl);
68-
}
69-
})
70-
.catch(function(err) {
71-
console.error(" - Failed to fetch " + url + " " + err.message);
51+
52+
return p.then(function() {
53+
return new Promise(function(resolve) {
54+
request({ method: "GET", uri: url }, function(err, response) {
55+
if (err) {
56+
console.error(" - Failed to fetch " + url + ": " + err.message);
57+
errors.push(displayUrl);
58+
resolve();
59+
} else if (response.statusCode != 200) {
60+
console.error(" - Got non-200 response for " + url + ": " + response.statusCode);
7261
errors.push(displayUrl);
73-
});
62+
resolve();
63+
} else {
64+
console.log("OKAY: " + displayUrl);
65+
resolve();
66+
}
67+
});
7468
});
75-
}
69+
});
7670
},
7771
Promise.resolve()
7872
);

0 commit comments

Comments
 (0)
Please sign in to comment.