@paimaexample/npm-midnight-node 0.3.16 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binary.js +9 -7
- package/package.json +1 -1
package/binary.js
CHANGED
|
@@ -6,7 +6,7 @@ const path = require("path");
|
|
|
6
6
|
|
|
7
7
|
function getPlatform() {
|
|
8
8
|
let platform = os.platform();
|
|
9
|
-
|
|
9
|
+
let arch = os.arch();
|
|
10
10
|
if (platform === "darwin") platform = "macos";
|
|
11
11
|
if (arch === "x64") arch = "amd64";
|
|
12
12
|
return `${platform}-${arch}`;
|
|
@@ -25,13 +25,15 @@ async function downloadAndSaveBinary() {
|
|
|
25
25
|
const url = getBinaryUrl();
|
|
26
26
|
try {
|
|
27
27
|
const response = await axios.get(url, { responseType: "stream" });
|
|
28
|
-
const writer = fs.createWriteStream(
|
|
29
|
-
|
|
28
|
+
const writer = fs.createWriteStream(
|
|
29
|
+
path.join(__dirname, "midnight-node.zip"),
|
|
30
|
+
);
|
|
31
|
+
|
|
30
32
|
response.data.pipe(writer);
|
|
31
|
-
|
|
33
|
+
|
|
32
34
|
return new Promise((resolve, reject) => {
|
|
33
|
-
writer.on(
|
|
34
|
-
writer.on(
|
|
35
|
+
writer.on("finish", resolve);
|
|
36
|
+
writer.on("error", reject);
|
|
35
37
|
});
|
|
36
38
|
} catch (error) {
|
|
37
39
|
console.error("Error downloading binary:", error);
|
|
@@ -53,4 +55,4 @@ async function binary() {
|
|
|
53
55
|
|
|
54
56
|
module.exports = {
|
|
55
57
|
binary,
|
|
56
|
-
};
|
|
58
|
+
};
|