Skip to content

Commit

Permalink
fixing hang in alpine linux and adding test (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryhinchey authored Feb 26, 2020
1 parent 80df989 commit cc2f270
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 7 additions & 0 deletions __tests__/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ const cases = {
string: '3.4.3\n Installed: rpm-4.11.3-35.el7.x86_64 at 2019-03-05 17:35\n',
version: '3.4.3',
},
ash: {
string: `
BusyBox v1.31.1 () multi-call binary.
Usage: ash [-/+OPTIONS] [-/+o OPT]... [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS] / -s [ARGS]]`,
version: '1.31.1',
},
bash: {
string: 'GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin17.0.0)',
version: '4.4.12',
Expand Down
13 changes: 8 additions & 5 deletions src/helpers/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = {
} else if (utils.isLinux) {
version = utils.run('cat /etc/os-release').then(v => {
const distro = (v || '').match(/NAME="(.+)"/);
const versionInfo = (v || '').match(/VERSION="(.+)"/) || null;
const versionInfo = (v || '').match(/VERSION="(.+)"/) || ['', ''];
const versionStr = versionInfo !== null ? versionInfo[1] : '';
return `${distro[1]} ${versionStr}`.trim() || '';
});
Expand All @@ -64,10 +64,13 @@ module.exports = {
if (utils.isMacOS || utils.isLinux) {
const shell =
process.env.SHELL || utils.runSync('getent passwd $LOGNAME | cut -d: -f7 | head -1');
return Promise.all([
utils.run(`${shell} --version`).then(utils.findVersion),
utils.which(shell),
]).then(v => utils.determineFound('Shell', v[0] || 'Unknown', v[1]));

let command = `${shell} --version 2>&1`;
if (shell.match('/bin/ash')) command = `${shell} --help 2>&1`;

return Promise.all([utils.run(command).then(utils.findVersion), utils.which(shell)]).then(v =>
utils.determineFound('Shell', v[0] || 'Unknown', v[1])
);
}
return Promise.resolve(['Shell', 'N/A']);
},
Expand Down

0 comments on commit cc2f270

Please sign in to comment.