ramorie 2.2.1 ā 2.2.3
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/package.json +1 -1
- package/postinstall.js +16 -9
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -72,16 +72,20 @@ async function main() {
|
|
|
72
72
|
const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`;
|
|
73
73
|
|
|
74
74
|
const binDir = path.join(__dirname, 'bin');
|
|
75
|
+
const tempDir = path.join(__dirname, 'temp-extract');
|
|
75
76
|
const tempFile = path.join(__dirname, `ramorie-temp.${ext}`);
|
|
76
77
|
const binaryPath = path.join(binDir, binaryName);
|
|
77
78
|
|
|
78
79
|
console.log(`š¦ Installing Ramorie v${VERSION} for ${platform}/${arch}...`);
|
|
79
80
|
|
|
80
81
|
try {
|
|
81
|
-
// Ensure
|
|
82
|
+
// Ensure directories exist
|
|
82
83
|
if (!fs.existsSync(binDir)) {
|
|
83
84
|
fs.mkdirSync(binDir, { recursive: true });
|
|
84
85
|
}
|
|
86
|
+
if (!fs.existsSync(tempDir)) {
|
|
87
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
88
|
+
}
|
|
85
89
|
|
|
86
90
|
// Download the archive
|
|
87
91
|
console.log(` Downloading...`);
|
|
@@ -89,18 +93,18 @@ async function main() {
|
|
|
89
93
|
fs.writeFileSync(tempFile, data);
|
|
90
94
|
console.log(' ā Downloaded');
|
|
91
95
|
|
|
92
|
-
// Extract
|
|
96
|
+
// Extract to temp directory (not bin!) to avoid overwriting shim
|
|
93
97
|
console.log(' Extracting...');
|
|
94
98
|
const extractedBinary = isWindows ? 'ramorie.exe' : 'ramorie';
|
|
95
|
-
const extractedPath = path.join(
|
|
96
|
-
|
|
99
|
+
const extractedPath = path.join(tempDir, extractedBinary);
|
|
100
|
+
|
|
97
101
|
if (isWindows) {
|
|
98
|
-
execSync(`powershell -command "Expand-Archive -Path '${tempFile}' -DestinationPath '${
|
|
102
|
+
execSync(`powershell -command "Expand-Archive -Path '${tempFile}' -DestinationPath '${tempDir}' -Force"`, { stdio: 'pipe' });
|
|
99
103
|
} else {
|
|
100
|
-
execSync(`tar -xzf "${tempFile}" -C "${
|
|
104
|
+
execSync(`tar -xzf "${tempFile}" -C "${tempDir}"`, { stdio: 'pipe' });
|
|
101
105
|
}
|
|
102
|
-
|
|
103
|
-
//
|
|
106
|
+
|
|
107
|
+
// Move only the binary to bin/ with new name
|
|
104
108
|
if (fs.existsSync(extractedPath)) {
|
|
105
109
|
fs.renameSync(extractedPath, binaryPath);
|
|
106
110
|
}
|
|
@@ -111,10 +115,13 @@ async function main() {
|
|
|
111
115
|
fs.chmodSync(binaryPath, 0o755);
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
// Cleanup
|
|
118
|
+
// Cleanup temp files and directory
|
|
115
119
|
if (fs.existsSync(tempFile)) {
|
|
116
120
|
fs.unlinkSync(tempFile);
|
|
117
121
|
}
|
|
122
|
+
if (fs.existsSync(tempDir)) {
|
|
123
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
124
|
+
}
|
|
118
125
|
|
|
119
126
|
console.log(`\nā
Ramorie v${VERSION} installed successfully!`);
|
|
120
127
|
console.log(' Run "ramorie --help" to get started.\n');
|