console2svg 0.7.0 → 0.8.0
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/cli/install.js +41 -32
- package/package.json +3 -2
package/cli/install.js
CHANGED
|
@@ -40,9 +40,9 @@ if (platform === 'win32') {
|
|
|
40
40
|
|
|
41
41
|
const isWin = platform === 'win32';
|
|
42
42
|
const distDir = path.join(__dirname, '..', 'dist');
|
|
43
|
-
const
|
|
43
|
+
const binaryPath = path.join(distDir, `console2svg${isWin ? '.exe' : ''}`);
|
|
44
44
|
|
|
45
|
-
if (fs.existsSync(
|
|
45
|
+
if (fs.existsSync(binaryPath)) {
|
|
46
46
|
process.exit(0);
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -66,7 +66,8 @@ function download(downloadUrl, redirects, onFinish) {
|
|
|
66
66
|
const agent = proxy ? new HttpsProxyAgent(proxy) : undefined;
|
|
67
67
|
const urlObj = new URL(downloadUrl);
|
|
68
68
|
|
|
69
|
-
const
|
|
69
|
+
const archiveName = isWin ? `console2svg-${rid}.zip` : `console2svg-${rid}.tar.gz`;
|
|
70
|
+
const tempPath = path.join(distDir, `${archiveName}.tmp`);
|
|
70
71
|
|
|
71
72
|
const request = https.get(
|
|
72
73
|
{
|
|
@@ -105,11 +106,11 @@ function download(downloadUrl, redirects, onFinish) {
|
|
|
105
106
|
});
|
|
106
107
|
file.on('error', (err) => {
|
|
107
108
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
fs.unlinkSync(tempPath);
|
|
110
|
+
} catch {
|
|
111
|
+
// ignore
|
|
112
|
+
}
|
|
113
|
+
fail('console2svg: write failed.', err);
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
116
|
);
|
|
@@ -119,47 +120,55 @@ function download(downloadUrl, redirects, onFinish) {
|
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
const archiveFileName = isWin
|
|
124
|
+
? `console2svg-${rid}.zip`
|
|
125
|
+
: `console2svg-${rid}.tar.gz`;
|
|
126
|
+
const archiveUrl = `https://github.com/arika0093/console2svg/releases/download/v${version}/${archiveFileName}`;
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
download(archiveUrl, 0, (tempArchivePath) => {
|
|
129
|
+
if (isWin) {
|
|
129
130
|
const psEscape = (p) => p.replace(/'/g, "''");
|
|
130
|
-
// Extract the zip into distDir using PowerShell
|
|
131
131
|
const result = spawnSync(
|
|
132
132
|
'powershell',
|
|
133
133
|
[
|
|
134
134
|
'-NoProfile',
|
|
135
135
|
'-NonInteractive',
|
|
136
136
|
'-Command',
|
|
137
|
-
`Expand-Archive -LiteralPath '${psEscape(
|
|
137
|
+
`Expand-Archive -LiteralPath '${psEscape(tempArchivePath)}' -DestinationPath '${psEscape(distDir)}' -Force`
|
|
138
138
|
],
|
|
139
139
|
{ stdio: 'inherit' }
|
|
140
140
|
);
|
|
141
141
|
|
|
142
|
-
try { fs.unlinkSync(
|
|
142
|
+
try { fs.unlinkSync(tempArchivePath); } catch { /* ignore */ }
|
|
143
143
|
|
|
144
144
|
if (result.status !== 0) {
|
|
145
145
|
fail('console2svg: failed to extract zip bundle.');
|
|
146
146
|
}
|
|
147
|
+
} else {
|
|
148
|
+
const result = spawnSync(
|
|
149
|
+
'tar',
|
|
150
|
+
['-xzf', tempArchivePath, '-C', distDir],
|
|
151
|
+
{ stdio: 'inherit' }
|
|
152
|
+
);
|
|
147
153
|
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
try { fs.unlinkSync(tempArchivePath); } catch { /* ignore */ }
|
|
155
|
+
|
|
156
|
+
if (result.status !== 0) {
|
|
157
|
+
fail('console2svg: failed to extract tar.gz bundle.');
|
|
150
158
|
}
|
|
151
159
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
}
|
|
160
|
+
if (!isWin) {
|
|
161
|
+
try {
|
|
162
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
fail('console2svg: failed to make binary executable.', err);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!fs.existsSync(binaryPath)) {
|
|
170
|
+
fail(`console2svg: expected binary not found at ${binaryPath} after extraction.`);
|
|
171
|
+
}
|
|
165
172
|
|
|
173
|
+
process.exit(0);
|
|
174
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "console2svg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Convert terminal output into SVG images",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"win32"
|
|
32
32
|
],
|
|
33
33
|
"cpu": [
|
|
34
|
-
"x64"
|
|
34
|
+
"x64",
|
|
35
|
+
"arm64"
|
|
35
36
|
],
|
|
36
37
|
"preferGlobal": true
|
|
37
38
|
}
|