Add --open / --no-open to yarn flipper-server

Summary: As a convenience, open the browser by default when starting up

Reviewed By: timur-valiev

Differential Revision: D32984536

fbshipit-source-id: 540abf594f2f2553880f587bcd7d4811ea36fe74
This commit is contained in:
Michel Weststrate
2021-12-13 05:46:42 -08:00
committed by Facebook GitHub Bot
parent 73c6e8ee05
commit 6f9983eb42
2 changed files with 16 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import Watchman from './watchman';
import {serverDir} from './paths';
import isFB from './isFB';
import yargs from 'yargs';
import open from 'open';
const argv = yargs
.usage('yarn start [args]')
@@ -59,6 +60,11 @@ const argv = yargs
'Build the server without watching for changing or starting the service',
type: 'boolean',
},
open: {
describe: 'Open Flipper in the default browser after starting',
type: 'boolean',
default: true,
},
})
.version('DEV')
.help()
@@ -186,6 +192,14 @@ async function startWatchChanges() {
await compileServerMain();
} else {
await startWatchChanges();
restartServer(); // builds and starts
// builds and starts
await restartServer();
if (argv.open) {
setTimeout(() => {
// TODO: make port configurable together with flipper-server
open('http://localhost:52342/index.web.dev.html');
}, 2000);
}
}
})();