From 1978efd84ab4a1de8bfcc5b6ad8c0b19a4b78afc Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Mon, 11 Mar 2019 23:24:32 +0530 Subject: [PATCH] Bug fixes :construction: --- lib/commands/serve/launch.js | 8 +++----- lib/commands/serve/setup.js | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/commands/serve/launch.js b/lib/commands/serve/launch.js index 6fd1399eb..1f3c2c505 100644 --- a/lib/commands/serve/launch.js +++ b/lib/commands/serve/launch.js @@ -6,9 +6,7 @@ const logUpdate = require('log-update'); const opn = require('opn'); const shell = require('shelljs'); -const { projectTemplate } = require('./setup'); - -exports.serveProject = async (launchCmd) => { +exports.serveProject = async (launchCmd, projectTemplate) => { let frame = elegantSpinner(); let spinner = setInterval(() => { logUpdate(chalk.green.bold('\n Installing dependencies in the background. Hold on... ') + chalk.cyan.bold.dim(frame())); @@ -19,7 +17,7 @@ exports.serveProject = async (launchCmd) => { if (launchCmd === 'npm run dev') { port = projectTemplate === 'Nuxt-js' ? '3000' : '8080'; } else { - port = projectTemplate === 'graphql' ? '9000/api' : '9000/graphql'; + port = projectTemplate === 'graphql' ? '9000/graphql' : '9000/api'; } shell.exec('npm install', {silent: true}, async (err) => { clearInterval(spinner); @@ -29,9 +27,9 @@ exports.serveProject = async (launchCmd) => { process.exit(1); } console.log(chalk.green.bold(`You're all set.`)); - console.log(chalk.cyan.bold(`\n Available on ${chalk.green.bold(`${rootPath}:${port}`)}`)); try { await require('child_process').exec(launchCmd); + console.log(chalk.cyan.bold(`\n Available on ${chalk.green.bold(`${rootPath}:${port}`)}`)); } catch (err) { throw err; } diff --git a/lib/commands/serve/setup.js b/lib/commands/serve/setup.js index fc3dcb669..0282d5a42 100644 --- a/lib/commands/serve/setup.js +++ b/lib/commands/serve/setup.js @@ -10,7 +10,7 @@ const { showBanner } = require('../../external/banner'); let projectTemplate; -const setupProject = () => { +exports.setupProject = () => { showBanner(); configFileExists(); @@ -24,20 +24,19 @@ const setupProject = () => { .then(async (choice) => { let launchCmd = choice.side === 'client' ? 'npm run dev' : 'npm start'; + await appData() + .then((data) => { + projectTemplate = data.template; + }); + if (choice.side === 'client') { - await appData() - .then((data) => { - projectTemplate = data.template; - if (data.template !== 'Nuxt-js') { - shell.cd('client'); - } - }); + if (projectTemplate !== 'Nuxt-js') { + shell.cd('client'); + } } else { shell.cd('server'); } - serveProject(launchCmd); + serveProject(launchCmd, projectTemplate); }); }, 200); }; - -Object.assign(exports, {setupProject, projectTemplate})