Skip to content

Commit

Permalink
Merge pull request jimbojsb#13 from jimbojsb/jimbojsbgh-13
Browse files Browse the repository at this point in the history
Scan doen't find Homebrew binary
  • Loading branch information
jimbojsb committed Feb 14, 2014
2 parents 1e9a697 + 6dd73d9 commit edf9b32
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions LaunchRocket/ServiceManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,19 @@ -(void) cleanServicesFile {
-(IBAction) handleHomebrewScanClick:(id)sender {

Process *p = [[Process alloc] init];
NSFileManager *fm = [[NSFileManager alloc] init];

// try the most common way to get your homebrew prefix
NSString *homebrewPath = [p execute:@"source ~/.bash_profile && source ~/.bashrc && brew --prefix"];
homebrewPath = @"";
NSArray *filesToMaybeSource = @[@".bash_profile", @".bashrc", @".profile"];
NSMutableArray *filesToSource = [[NSMutableArray alloc] init];
for (NSString *file in filesToMaybeSource) {
NSString *filePath = [NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), file];
if ([fm fileExistsAtPath:filePath]) {
[filesToSource addObject:[NSString stringWithFormat:@"source %@", filePath]];
}
}
NSString *homebrewBashCommand = [NSString stringWithFormat:@"%@ && brew --prefix", [filesToSource componentsJoinedByString:@" && "]];
NSString *homebrewPath = [p execute:homebrewBashCommand];

//if that doesn't work, we need the path to your brew executable
if ([homebrewPath isEqualToString:@""]) {
Expand Down Expand Up @@ -98,7 +107,6 @@ -(IBAction) handleHomebrewScanClick:(id)sender {


NSString *optPath = [NSString stringWithFormat:@"%@/opt/", homebrewPath];
NSFileManager *fm = [[NSFileManager alloc] init];
NSDirectoryEnumerator *de = [fm enumeratorAtPath:optPath];
for (NSString *item in de) {
NSString *servicePlist = [NSString stringWithFormat:@"%@%@%@%@%@", optPath, item, @"/homebrew.mxcl.", item, @".plist"];
Expand Down

0 comments on commit edf9b32

Please sign in to comment.