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:
committed by
Facebook GitHub Bot
parent
73c6e8ee05
commit
6f9983eb42
@@ -170,6 +170,7 @@
|
|||||||
"metro-minify-terser": "^0.66.2",
|
"metro-minify-terser": "^0.66.2",
|
||||||
"metro-resolver": "^0.66.2",
|
"metro-resolver": "^0.66.2",
|
||||||
"node-fetch": "^2.6.6",
|
"node-fetch": "^2.6.6",
|
||||||
|
"open": "^8.3.0",
|
||||||
"p-filter": "^2.1.0",
|
"p-filter": "^2.1.0",
|
||||||
"p-map": "^4.0.0",
|
"p-map": "^4.0.0",
|
||||||
"patch-package": "^6.4.7",
|
"patch-package": "^6.4.7",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import Watchman from './watchman';
|
|||||||
import {serverDir} from './paths';
|
import {serverDir} from './paths';
|
||||||
import isFB from './isFB';
|
import isFB from './isFB';
|
||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
|
import open from 'open';
|
||||||
|
|
||||||
const argv = yargs
|
const argv = yargs
|
||||||
.usage('yarn start [args]')
|
.usage('yarn start [args]')
|
||||||
@@ -59,6 +60,11 @@ const argv = yargs
|
|||||||
'Build the server without watching for changing or starting the service',
|
'Build the server without watching for changing or starting the service',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
|
open: {
|
||||||
|
describe: 'Open Flipper in the default browser after starting',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.version('DEV')
|
.version('DEV')
|
||||||
.help()
|
.help()
|
||||||
@@ -186,6 +192,14 @@ async function startWatchChanges() {
|
|||||||
await compileServerMain();
|
await compileServerMain();
|
||||||
} else {
|
} else {
|
||||||
await startWatchChanges();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user