Permalink
Browse files

`@phenomic/core`: add preview command to build & serve results

  • Loading branch information...
MoOx committed May 5, 2018
1 parent 15841bb commit c2e0ecc9c7d6d75b4817eb7551dc690e4280081f
Showing with 311 additions and 30 deletions.
  1. +1 −0 packages/core/package.json
  2. +21 −4 packages/core/src/index.js
  3. +289 −26 yarn.lock
@@ -30,6 +30,7 @@
"react-dev-utils": "^4.2.1",
"rimraf": "^2.5.4",
"sane": "^1.7.0",
"serve": "^6.5.6",
"socket.io": "^1.7.2",
"socket.io-client": "^1.7.2",
"url": "^0.11.0"
View
@@ -1,10 +1,12 @@
// @flow
import cosmiconfig from "cosmiconfig";
import serve from "serve";
import flattenConfiguration from "./configuration/flattenConfiguration.js";
import start from "./commands/start.js";
import build from "./commands/build.js";
import log from "./utils/log.js";
const shittyCatch = error => {
setTimeout(() => {
@@ -35,14 +37,29 @@ function normalizeConfiguration(
}
export default {
start(config?: PhenomicInputConfig) {
normalizeConfiguration(config)
start(inputConfig?: PhenomicInputConfig) {
normalizeConfiguration(inputConfig)
.then(start)
.catch(shittyCatch);
},
build(config?: PhenomicInputConfig) {
normalizeConfiguration(config)
build(inputConfig?: PhenomicInputConfig) {
normalizeConfiguration(inputConfig)
.then(build)
.catch(shittyCatch);
},
async preview(inputConfig?: PhenomicInputConfig) {
try {
const config = await normalizeConfiguration(inputConfig);
await build(config);
log(
`⚡️ Serving on http://localhost:${config.port}` +
config.baseUrl.pathname
);
serve(config.outdir, {
port: config.port
});
} catch (e) {
shittyCatch(e);
}
}
};
Oops, something went wrong.

0 comments on commit c2e0ecc

Please sign in to comment.