Skip to content

Commit

Permalink
fix: be more tolerant when detecting Android Studio IDE on OSX (#252)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiawen Geng <technicalcute@gmail.com>
  • Loading branch information
Nthalk and gengjiawen committed Apr 29, 2024
1 parent 25572bf commit eb9e5de
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@
"bug",
"code"
]
},
{
"login": "Nthalk",
"name": "Carl Taylor",
"avatar_url": "https://avatars.githubusercontent.com/u/174297?v=4",
"profile": "https://github.com/Nthalk",
"contributions": [
"code"
]
}
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>

[![npm version](https://badge.fury.io/js/envinfo.svg)](https://badge.fury.io/js/envinfo) [![npm downloads per month](https://img.shields.io/npm/dm/envinfo.svg?maxAge=86400)](https://www.npmjs.com/package/envinfo) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors)

## The problem

Expand Down Expand Up @@ -280,7 +280,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
<!-- prettier-ignore -->
| [<img src="https://avatars1.githubusercontent.com/u/2925048?v=4" width="100px;"/><br /><sub><b>Trevor Brindle</b></sub>](http://trevorbrindle.com)<br />[💬](#question-tabrindle "Answering Questions") [📝](#blog-tabrindle "Blogposts") [🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Atabrindle "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=tabrindle "Code") [📖](https://github.com/tabrindle/envinfo/commits?author=tabrindle "Documentation") [💡](#example-tabrindle "Examples") [🤔](#ideas-tabrindle "Ideas, Planning, & Feedback") [👀](#review-tabrindle "Reviewed Pull Requests") [📢](#talk-tabrindle "Talks") [⚠️](https://github.com/tabrindle/envinfo/commits?author=tabrindle "Tests") | [<img src="https://avatars0.githubusercontent.com/u/997157?v=4" width="100px;"/><br /><sub><b>Gant Laborde</b></sub>](http://gantlaborde.com/)<br />[📝](#blog-GantMan "Blogposts") [🐛](https://github.com/tabrindle/envinfo/issues?q=author%3AGantMan "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=GantMan "Code") [🤔](#ideas-GantMan "Ideas, Planning, & Feedback") | [<img src="https://avatars1.githubusercontent.com/u/599352?v=4" width="100px;"/><br /><sub><b>Anton Fisher</b></sub>](http://antonfisher.com)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Aantonfisher "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=antonfisher "Code") | [<img src="https://avatars1.githubusercontent.com/u/960133?v=4" width="100px;"/><br /><sub><b>Ahmad Awais ⚡️</b></sub>](https://AhmadAwais.com/)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Aahmadawais "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=ahmadawais "Code") | [<img src="https://avatars2.githubusercontent.com/u/9251453?v=4" width="100px;"/><br /><sub><b>Hasan</b></sub>](https://github.com/LEQADA)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3ALEQADA "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=LEQADA "Code") | [<img src="https://avatars3.githubusercontent.com/u/1232725?v=4" width="100px;"/><br /><sub><b>Ernesto Ramírez</b></sub>](http://twitter.com/_ErnestoR)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3AErnestoR "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=ErnestoR "Code") | [<img src="https://avatars1.githubusercontent.com/u/3759816?v=4" width="100px;"/><br /><sub><b>Jiawen Geng</b></sub>](https://www.gengjiawen.com)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Agengjiawen "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=gengjiawen "Code") [🤔](#ideas-gengjiawen "Ideas, Planning, & Feedback") [⚠️](https://github.com/tabrindle/envinfo/commits?author=gengjiawen "Tests") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars3.githubusercontent.com/u/12520493?v=4" width="100px;"/><br /><sub><b>Zac Anger</b></sub>](https://zacanger.com)<br />[💻](https://github.com/tabrindle/envinfo/commits?author=zacanger "Code") [🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Azacanger "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/497214?v=4" width="100px;"/><br /><sub><b>Ville Immonen</b></sub>](https://twitter.com/VilleImmonen)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Afson "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=fson "Code") | [<img src="https://avatars2.githubusercontent.com/u/27246?v=4" width="100px;"/><br /><sub><b>Olmo Maldonado</b></sub>](http://ibolmo.com)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Aibolmo "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=ibolmo "Code") | [<img src="https://avatars.githubusercontent.com/u/15812317?v=4" width="100px;"/><br /><sub><b>Rishabh Chawla</b></sub>](https://rishabhchawla.co)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Arishabh3112 "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=rishabh3112 "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/12520493?v=4" width="100px;"/><br /><sub><b>Zac Anger</b></sub>](https://zacanger.com)<br />[💻](https://github.com/tabrindle/envinfo/commits?author=zacanger "Code") [🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Azacanger "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/497214?v=4" width="100px;"/><br /><sub><b>Ville Immonen</b></sub>](https://twitter.com/VilleImmonen)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Afson "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=fson "Code") | [<img src="https://avatars2.githubusercontent.com/u/27246?v=4" width="100px;"/><br /><sub><b>Olmo Maldonado</b></sub>](http://ibolmo.com)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Aibolmo "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=ibolmo "Code") | [<img src="https://avatars.githubusercontent.com/u/15812317?v=4" width="100px;"/><br /><sub><b>Rishabh Chawla</b></sub>](https://rishabhchawla.co)<br />[🐛](https://github.com/tabrindle/envinfo/issues?q=author%3Arishabh3112 "Bug reports") [💻](https://github.com/tabrindle/envinfo/commits?author=rishabh3112 "Code") | [<img src="https://avatars.githubusercontent.com/u/174297?v=4" width="100px;"/><br /><sub><b>Carl Taylor</b></sub>](https://github.com/Nthalk)<br />[💻](https://github.com/tabrindle/envinfo/commits?author=Nthalk "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
62 changes: 37 additions & 25 deletions src/helpers/ides.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,44 @@ module.exports = {
getAndroidStudioInfo: () => {
let androidStudioVersion = Promise.resolve('N/A');
if (utils.isMacOS) {
androidStudioVersion = utils
.run(
utils.generatePlistBuddyCommand(
path.join('/', 'Applications', 'Android\\ Studio.app', 'Contents', 'Info.plist'),
['CFBundleShortVersionString', 'CFBundleVersion']
)
)
.then(version => {
if (!version) {
return utils.run(
utils.generatePlistBuddyCommand(
path.join(
'~',
'Applications',
'JetBrains\\ Toolbox',
'Android\\ Studio.app',
'Contents',
'Info.plist'
),
['CFBundleShortVersionString', 'CFBundleVersion']
)
);
}
return version;
const paths = [
path.join('/', 'Applications', 'Android Studio.app', 'Contents', 'Info.plist'),
path.join(process.env.HOME, 'Applications', 'Android Studio.app', 'Contents', 'Info.plist'),
path.join(
'/',
'Applications',
'JetBrains Toolbox',
'Android Studio.app',
'Contents',
'Info.plist'
),
path.join(
process.env.HOME,
'Applications',
'JetBrains Toolbox',
'Android Studio.app',
'Contents',
'Info.plist'
),
];
androidStudioVersion = Promise.all(
paths.map(p => {
return utils.fileExists(p).then(exists => {
if (!exists) {
return null;
}
const command = utils.generatePlistBuddyCommand(p.replace(/ /g, '\\ '), [
'CFBundleShortVersionString',
'CFBundleVersion',
]);
return utils.run(command).then(version => {
return version.split('\n').join(' ');
});
});
})
.then(version => version.split('\n').join(' '));
).then(versions => {
return versions.find(version => version !== null) || utils.NotFound;
});
} else if (utils.isLinux) {
androidStudioVersion = Promise.all([
utils
Expand Down

0 comments on commit eb9e5de

Please sign in to comment.