From 3899e49f2a0830469c48d4cd67996caa16caa5ec Mon Sep 17 00:00:00 2001 From: maxmellon Date: Wed, 4 Sep 2019 19:12:03 +0900 Subject: [PATCH] feat(fusuma): add option of port to the 'start-task'. --- packages/cli/src/fusuma.js | 3 ++- packages/fusuma/src/tasks.js | 5 +++-- packages/webpack/src/index.js | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/fusuma.js b/packages/cli/src/fusuma.js index 0106aa9f4..8f0451071 100644 --- a/packages/cli/src/fusuma.js +++ b/packages/cli/src/fusuma.js @@ -24,10 +24,11 @@ async function cli() { .command('start', 'Start with webpack-dev-server') .option('-d ', 'Directory to load') + .option('-p ', 'Dev server port') .action((args, options, logger) => { resolve({ type: 'start', - options: { dir: options.d } + options: { dir: options.d, port: options.p } }); }) diff --git a/packages/fusuma/src/tasks.js b/packages/fusuma/src/tasks.js index 91772a66f..c0bb601ee 100644 --- a/packages/fusuma/src/tasks.js +++ b/packages/fusuma/src/tasks.js @@ -13,13 +13,14 @@ async function initProcess({ schema }) { await init(process.cwd(), schema); } -async function startProcess(basePath) { +async function startProcess(basePath, { port }) { const spinner = loader('Starting server...').start(); const config = fusuma.combine(await fusuma.read(basePath)); const remoteOrigin = await getRemoteOriginUrl(); await start({ ...config, + port, internal: { basePath, remoteOrigin @@ -146,7 +147,7 @@ function tasks({ type, options }) { case 'init': return initProcess(options); case 'start': - return startProcess(basePath); + return startProcess(basePath, options); case 'build': return buildProcess(basePath); case 'deploy': diff --git a/packages/webpack/src/index.js b/packages/webpack/src/index.js index cedbb45cf..fe231ff7f 100644 --- a/packages/webpack/src/index.js +++ b/packages/webpack/src/index.js @@ -4,8 +4,9 @@ const combineConfig = require('./webpack.config'); async function start(config) { const server = require('./server'); + const port = config.port || 8080 - return await server(combineConfig('development', config), { port: 8080 }); + return await server(combineConfig('development', config), { port }); } async function build(config, isConsoleOutput = true, cb) {