sshifu 0.7.8-test.8 → 0.7.9
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/scripts/install.js +6 -45
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -90,28 +90,12 @@ async function main() {
|
|
|
90
90
|
try {
|
|
91
91
|
await download(archiveUrl, archivePath);
|
|
92
92
|
|
|
93
|
-
// Small delay to ensure file handle is released
|
|
94
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
95
|
-
|
|
96
93
|
// Extract the archive
|
|
97
94
|
console.log(`[sshifu] Extracting...`);
|
|
98
95
|
const archiveBinName = `${PACKAGE_NAME}-${platform}${isWindows ? '.exe' : ''}`;
|
|
99
96
|
const extractedPath = path.join(binDir, archiveBinName);
|
|
100
97
|
if (isWindows) {
|
|
101
|
-
|
|
102
|
-
// Use PowerShell with explicit error action and output redirection
|
|
103
|
-
const psCommand = `Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force -ErrorAction Stop`;
|
|
104
|
-
console.log(`[sshifu] Running: ${psCommand}`);
|
|
105
|
-
execSync(`powershell -Command "${psCommand}"`, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
106
|
-
console.log(`[sshifu] Extraction completed, checking files...`);
|
|
107
|
-
const afterExtract = fs.readdirSync(binDir);
|
|
108
|
-
console.log(`[sshifu] Files after extraction: ${afterExtract.join(', ')}`);
|
|
109
|
-
} catch (extractErr) {
|
|
110
|
-
console.error(`[sshifu] Extraction failed: ${extractErr.message}`);
|
|
111
|
-
console.error(`[sshifu] stderr: ${extractErr.stderr?.toString() || 'N/A'}`);
|
|
112
|
-
console.error(`[sshifu] stdout: ${extractErr.stdout?.toString() || 'N/A'}`);
|
|
113
|
-
throw extractErr;
|
|
114
|
-
}
|
|
98
|
+
execSync(`powershell -Command "Expand-Archive -Path '${archivePath.replace(/'/g, "''")}' -DestinationPath '${binDir.replace(/'/g, "''")}' -Force"`, { stdio: 'ignore' });
|
|
115
99
|
} else {
|
|
116
100
|
execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'ignore' });
|
|
117
101
|
}
|
|
@@ -125,35 +109,12 @@ async function main() {
|
|
|
125
109
|
fs.renameSync(extractedPath, binPath);
|
|
126
110
|
} else {
|
|
127
111
|
// Try to find the extracted file (in case of path issues)
|
|
128
|
-
console.log(`[sshifu] Binary not found at expected location, searching...`);
|
|
129
112
|
const files = fs.readdirSync(binDir);
|
|
130
|
-
console.log(`[sshifu] Files in binDir
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const filePath = path.join(binDir, file);
|
|
136
|
-
const stat = fs.statSync(filePath);
|
|
137
|
-
if (stat.isDirectory()) {
|
|
138
|
-
// Check subdirectory
|
|
139
|
-
const subFiles = fs.readdirSync(filePath);
|
|
140
|
-
console.log(`[sshifu] Files in ${file}/: ${subFiles.join(', ')}`);
|
|
141
|
-
const exeInSubdir = subFiles.find(f => f.endsWith('.exe') && f.startsWith(PACKAGE_NAME));
|
|
142
|
-
if (exeInSubdir) {
|
|
143
|
-
foundFile = path.join(filePath, exeInSubdir);
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
} else if (file.endsWith('.exe') && file.startsWith(PACKAGE_NAME)) {
|
|
147
|
-
foundFile = filePath;
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (foundFile) {
|
|
153
|
-
console.log(`[sshifu] Found ${foundFile}, renaming to ${binName}`);
|
|
154
|
-
fs.renameSync(foundFile, binPath);
|
|
155
|
-
} else {
|
|
156
|
-
throw new Error(`Could not find binary in ${binDir}`);
|
|
113
|
+
console.log(`[sshifu] Files in binDir: ${files.join(', ')}`);
|
|
114
|
+
const exeFile = files.find(f => f.endsWith('.exe') && f.startsWith(PACKAGE_NAME));
|
|
115
|
+
if (exeFile) {
|
|
116
|
+
console.log(`[sshifu] Found ${exeFile}, renaming to ${binName}`);
|
|
117
|
+
fs.renameSync(path.join(binDir, exeFile), binPath);
|
|
157
118
|
}
|
|
158
119
|
}
|
|
159
120
|
}
|