@scottymade/mana 1.0.2 → 1.0.4
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/bin/mana +8 -2
- package/package.json +1 -1
- package/scripts/postinstall.js +9 -31
package/bin/mana
CHANGED
|
@@ -9,8 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
set -e
|
|
11
11
|
|
|
12
|
-
# Get the directory where this script is located
|
|
13
|
-
|
|
12
|
+
# Get the directory where this script is located (resolving symlinks)
|
|
13
|
+
SOURCE="$0"
|
|
14
|
+
while [ -L "$SOURCE" ]; do
|
|
15
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
16
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
17
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
18
|
+
done
|
|
19
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
14
20
|
|
|
15
21
|
# Try to find the binary
|
|
16
22
|
# First, check for the symlink/copy created by postinstall
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -54,40 +54,18 @@ function getBinaryName() {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Download a file from URL to destination
|
|
58
|
-
*
|
|
57
|
+
* Download a file from URL to destination using curl
|
|
58
|
+
* More reliable than Node https for following GitHub redirects
|
|
59
59
|
*/
|
|
60
60
|
function downloadFile(url, dest) {
|
|
61
61
|
return new Promise((resolve, reject) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
request(redirectUrl);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (response.statusCode !== 200) {
|
|
74
|
-
reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
response.pipe(file);
|
|
79
|
-
|
|
80
|
-
file.on('finish', () => {
|
|
81
|
-
file.close();
|
|
82
|
-
resolve();
|
|
83
|
-
});
|
|
84
|
-
}).on('error', (err) => {
|
|
85
|
-
fs.unlink(dest, () => {}); // Delete partial file
|
|
86
|
-
reject(err);
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
request(url);
|
|
62
|
+
try {
|
|
63
|
+
// Use curl which handles redirects properly
|
|
64
|
+
execSync(`curl -fsSL "${url}" -o "${dest}"`, { stdio: 'pipe' });
|
|
65
|
+
resolve();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
reject(new Error(`Failed to download: ${error.message}`));
|
|
68
|
+
}
|
|
91
69
|
});
|
|
92
70
|
}
|
|
93
71
|
|