Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
[xdl] Start Ngrok only when running expo start --tunnel (#2088)
Browse files Browse the repository at this point in the history
* [xdl]  Start Ngrok only when running expo start --tunnel

Fixes #335

* this doesn't actually return packagerOpts, so destructure instead of using incorrect name

* [dev-tools] toggling 'tunnel' in DevTools should start tunnels

* Update packages/dev-tools/server/graphql/GraphQLSchema.ts

Co-authored-by: Ville Immonen <ville.immonen@iki.fi>

Co-authored-by: Ville Immonen <ville.immonen@iki.fi>
  • Loading branch information
FiberJW and fson authored May 12, 2020
1 parent c190cad commit 8b09997
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/dev-tools/server/graphql/GraphQLSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,22 @@ const resolvers = {
},
async setProjectSettings(parent, { settings }, context) {
const currentProject = context.getCurrentProject();
let previousSettings = await ProjectSettings.readAsync(currentProject.projectDir);
let updatedSettings = await ProjectSettings.setAsync(currentProject.projectDir, settings);

// If 'tunnel' wasn't previously configured and it will be as a result of this request, start tunnels.
if (previousSettings.hostType !== 'tunnel' && updatedSettings.hostType === 'tunnel') {
try {
await Project.startTunnelsAsync(currentProject.projectDir);
} catch (e) {
ProjectUtils.logWarning(
currentProject.projectDir,
'expo',
`Error starting tunnel ${e.message}`
);
}
}

return {
...currentProject,
settings: updatedSettings,
Expand Down
4 changes: 3 additions & 1 deletion packages/xdl/src/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,9 @@ export async function startAsync(
DevSession.startSession(projectRoot, exp, 'native');
}

if (!Config.offline) {
const { hostType } = await ProjectSettings.readAsync(projectRoot);

if (!Config.offline && hostType === 'tunnel') {
try {
await startTunnelsAsync(projectRoot);
} catch (e) {
Expand Down

0 comments on commit 8b09997

Please sign in to comment.