Skip to content

Commit 84b9d01

Browse files
authored
feat: add 7z support (#283)
1 parent 6085189 commit 84b9d01

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
image:
22
- Visual Studio 2022
3-
3+
44
environment:
55
nodejs_version: '24'
66

@@ -14,9 +14,9 @@ test_script:
1414
- choco install r.project -version 3.6.0
1515
- set RPATH=C:\Program Files\R\R-3.6.0\bin\x64
1616
- set PATH=%RPATH%;%PATH%
17+
- node src/cli.js
1718
- SET ENVINFO_DEBUG=trace
1819
- npm run build
19-
- node src/cli.js
2020
- node dist/cli.js
2121
- SET ENVINFO_DEBUG=""
2222
- npm test

src/helpers/utilities.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,44 @@ module.exports = {
124124
utils.which('ccache'),
125125
]).then(v => utils.determineFound('ccache', v[0], v[1]));
126126
},
127+
128+
get7zInfo: () => {
129+
utils.log('trace', 'get7zInfo');
130+
const candidates = ['7z', '7zz'];
131+
132+
const findFirstWhich = () =>
133+
Promise.all(candidates.map(bin => utils.which(bin))).then(paths => {
134+
const idx = paths.findIndex(Boolean);
135+
return idx >= 0 ? { bin: candidates[idx], path: paths[idx] } : null;
136+
});
137+
138+
if (utils.isWindows) {
139+
// Try default install location first
140+
return utils.windowsExeExists('7-Zip/7z.exe').then(filePath => {
141+
if (filePath) {
142+
return Promise.all([
143+
utils.run(`powershell "& '${filePath}' i | Write-Output"`).then(utils.findVersion),
144+
Promise.resolve(filePath),
145+
]).then(v => utils.determineFound('7z', v[0], v[1]));
146+
}
147+
// Fallback to PATH candidates
148+
return findFirstWhich().then(found => {
149+
if (!found) return utils.determineFound('7z', '', undefined);
150+
return Promise.all([
151+
utils.run(`${found.bin} i`).then(utils.findVersion),
152+
Promise.resolve(found.path),
153+
]).then(v => utils.determineFound('7z', v[0], v[1]));
154+
});
155+
});
156+
}
157+
158+
// macOS/Linux: find on PATH among common names
159+
return findFirstWhich().then(found => {
160+
if (!found) return utils.determineFound('7z', '', undefined);
161+
return Promise.all([
162+
utils.run(`${found.bin} i`).then(utils.findVersion),
163+
Promise.resolve(found.path),
164+
]).then(v => utils.determineFound('7z', v[0], v[1]));
165+
});
166+
},
127167
};

src/presets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
'Yum',
1717
],
1818
Utilities: [
19+
'7z',
1920
'Bazel',
2021
'CMake',
2122
'Make',

0 commit comments

Comments
 (0)