From e5d9906d800ed98984cb8e012876e874ae38f327 Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Wed, 27 Sep 2017 11:09:22 +0200 Subject: [PATCH] feat(local-cli): implement "hops start" command --- packages/local-cli/commands/start.js | 19 +++++++++++++++++++ packages/local-cli/run.js | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 packages/local-cli/commands/start.js diff --git a/packages/local-cli/commands/start.js b/packages/local-cli/commands/start.js new file mode 100644 index 000000000..d8ea67170 --- /dev/null +++ b/packages/local-cli/commands/start.js @@ -0,0 +1,19 @@ +'use strict'; + +var hopsBuild = require('hops-build'); +var hopsExpress = require('hops-express'); + +module.exports = function startCommand (callback) { + return { + command: 'start', + describe: 'Starts a development or production server, based on NODE_ENV', + builder: {}, + handler: function startHandler (argv) { + if (process.env.NODE_ENV === 'production') { + hopsExpress.startServer(callback); + } else { + hopsBuild.runServer(argv, callback); + } + } + }; +}; diff --git a/packages/local-cli/run.js b/packages/local-cli/run.js index eac735638..33456d5ed 100755 --- a/packages/local-cli/run.js +++ b/packages/local-cli/run.js @@ -23,6 +23,13 @@ module.exports = function run (argv, callback) { args.command(require('./commands/serve')(callback)); } + if ( + pm.isPackageInstalled('hops-build') && + pm.isPackageInstalled('hops-express') + ) { + args.command(require('./commands/start')(callback)); + } + args.parse(argv); };