forked from react-native-community/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(doctor): Try installing packages with Homebrew (react-native-com…
- Loading branch information
Showing
4 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @flow | ||
import {logger} from '@react-native-community/cli-tools'; | ||
import execa from 'execa'; | ||
import Ora from 'ora'; | ||
|
||
async function brewInstall(pkg: string, loader: typeof Ora) { | ||
loader.start(`Installing ${pkg}`); | ||
try { | ||
await execa('brew', ['install', pkg]); | ||
loader.succeed(); | ||
} catch (error) { | ||
logger.log(error.stderr); | ||
loader.fail( | ||
`An error occured while trying to install ${pkg}. Please try again manually: brew install ${pkg}`, | ||
); | ||
} | ||
} | ||
|
||
export {brewInstall}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @flow | ||
import Ora from 'ora'; | ||
import {brewInstall} from './brewInstall'; | ||
|
||
async function install(pkg: string, source: string, loader: typeof Ora) { | ||
try { | ||
switch (process.platform) { | ||
case 'darwin': | ||
await brewInstall(pkg, loader); | ||
break; | ||
default: | ||
throw new Error('Not implemented yet'); | ||
} | ||
} catch (_error) { | ||
loader.info(`Please download and install '${pkg}' from ${source}.`); | ||
} | ||
} | ||
|
||
export {install}; |