Skip to content

Commit eb9e5de

Browse files
Nthalkgengjiawen
andauthored
fix: be more tolerant when detecting Android Studio IDE on OSX (#252)
Co-authored-by: Jiawen Geng <technicalcute@gmail.com>
1 parent 25572bf commit eb9e5de

3 files changed

Lines changed: 48 additions & 27 deletions

File tree

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@
130130
"bug",
131131
"code"
132132
]
133+
},
134+
{
135+
"login": "Nthalk",
136+
"name": "Carl Taylor",
137+
"avatar_url": "https://avatars.githubusercontent.com/u/174297?v=4",
138+
"profile": "https://github.com/Nthalk",
139+
"contributions": [
140+
"code"
141+
]
133142
}
134143
]
135144
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</p>
66

77
[![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)
8-
[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors)
8+
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors)
99

1010
## The problem
1111

@@ -280,7 +280,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
280280
<!-- prettier-ignore -->
281281
| [<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") |
282282
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
283-
| [<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") |
283+
| [<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") |
284284
<!-- ALL-CONTRIBUTORS-LIST:END -->
285285

286286
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

src/helpers/ides.js

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,44 @@ module.exports = {
55
getAndroidStudioInfo: () => {
66
let androidStudioVersion = Promise.resolve('N/A');
77
if (utils.isMacOS) {
8-
androidStudioVersion = utils
9-
.run(
10-
utils.generatePlistBuddyCommand(
11-
path.join('/', 'Applications', 'Android\\ Studio.app', 'Contents', 'Info.plist'),
12-
['CFBundleShortVersionString', 'CFBundleVersion']
13-
)
14-
)
15-
.then(version => {
16-
if (!version) {
17-
return utils.run(
18-
utils.generatePlistBuddyCommand(
19-
path.join(
20-
'~',
21-
'Applications',
22-
'JetBrains\\ Toolbox',
23-
'Android\\ Studio.app',
24-
'Contents',
25-
'Info.plist'
26-
),
27-
['CFBundleShortVersionString', 'CFBundleVersion']
28-
)
29-
);
30-
}
31-
return version;
8+
const paths = [
9+
path.join('/', 'Applications', 'Android Studio.app', 'Contents', 'Info.plist'),
10+
path.join(process.env.HOME, 'Applications', 'Android Studio.app', 'Contents', 'Info.plist'),
11+
path.join(
12+
'/',
13+
'Applications',
14+
'JetBrains Toolbox',
15+
'Android Studio.app',
16+
'Contents',
17+
'Info.plist'
18+
),
19+
path.join(
20+
process.env.HOME,
21+
'Applications',
22+
'JetBrains Toolbox',
23+
'Android Studio.app',
24+
'Contents',
25+
'Info.plist'
26+
),
27+
];
28+
androidStudioVersion = Promise.all(
29+
paths.map(p => {
30+
return utils.fileExists(p).then(exists => {
31+
if (!exists) {
32+
return null;
33+
}
34+
const command = utils.generatePlistBuddyCommand(p.replace(/ /g, '\\ '), [
35+
'CFBundleShortVersionString',
36+
'CFBundleVersion',
37+
]);
38+
return utils.run(command).then(version => {
39+
return version.split('\n').join(' ');
40+
});
41+
});
3242
})
33-
.then(version => version.split('\n').join(' '));
43+
).then(versions => {
44+
return versions.find(version => version !== null) || utils.NotFound;
45+
});
3446
} else if (utils.isLinux) {
3547
androidStudioVersion = Promise.all([
3648
utils

0 commit comments

Comments
 (0)