@mandors/cli 0.0.10 → 0.0.12
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.
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/npm/lib/install.js
CHANGED
|
@@ -56,34 +56,41 @@ async function install(options = {}) {
|
|
|
56
56
|
* @returns {string|null} Path to binary or null if not bundled
|
|
57
57
|
*/
|
|
58
58
|
function useBundledBinary(platform, arch) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const
|
|
59
|
+
const osArch = `${platform}-${arch}`;
|
|
60
|
+
const tarball = path.join(BUNDLE_DIR, `${osArch}.tar.gz`);
|
|
61
|
+
const cacheDir = path.join(os.homedir(), '.mandor', 'bin');
|
|
62
|
+
const dest = path.join(cacheDir, osArch);
|
|
62
63
|
|
|
63
|
-
console.log(`DEBUG: Looking for binary for ${
|
|
64
|
+
console.log(`DEBUG: Looking for binary for ${osArch}`);
|
|
64
65
|
console.log(`DEBUG: BUNDLE_DIR: ${BUNDLE_DIR}`);
|
|
65
66
|
console.log(`DEBUG: Files in BUNDLE_DIR: ${fs.readdirSync(BUNDLE_DIR).join(', ')}`);
|
|
66
67
|
|
|
67
|
-
if
|
|
68
|
-
|
|
68
|
+
// First check if binary already exists in cache
|
|
69
|
+
if (fs.existsSync(dest)) {
|
|
70
|
+
console.log(`DEBUG: Using cached binary: ${dest}`);
|
|
71
|
+
return dest;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check if tarball exists
|
|
75
|
+
if (!fs.existsSync(tarball)) {
|
|
76
|
+
console.log(`DEBUG: No tarball found at: ${tarball}`);
|
|
69
77
|
return null;
|
|
70
78
|
}
|
|
71
79
|
|
|
72
|
-
console.log(`DEBUG:
|
|
80
|
+
console.log(`DEBUG: Extracting tarball: ${tarball}`);
|
|
73
81
|
|
|
74
|
-
const cacheDir = path.join(os.homedir(), '.mandor', 'bin');
|
|
75
82
|
if (!fs.existsSync(cacheDir)) {
|
|
76
83
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
const dest = path.join(cacheDir, filename);
|
|
80
|
-
|
|
81
86
|
try {
|
|
82
|
-
|
|
87
|
+
const { execSync } = require('child_process');
|
|
88
|
+
execSync(`tar -xzf "${tarball}" -C "${cacheDir}"`, { stdio: 'pipe' });
|
|
83
89
|
fs.chmodSync(dest, '755');
|
|
90
|
+
console.log(`DEBUG: Extracted to: ${dest}`);
|
|
84
91
|
return dest;
|
|
85
92
|
} catch (e) {
|
|
86
|
-
console.log(`DEBUG: Failed to
|
|
93
|
+
console.log(`DEBUG: Failed to extract tarball: ${e.message}`);
|
|
87
94
|
return null;
|
|
88
95
|
}
|
|
89
96
|
}
|