Skip to content

Commit

Permalink
Bug fixes 🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Mar 11, 2019
1 parent 3e2d773 commit 1978efd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
8 changes: 3 additions & 5 deletions lib/commands/serve/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
21 changes: 10 additions & 11 deletions lib/commands/serve/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { showBanner } = require('../../external/banner');

let projectTemplate;

const setupProject = () => {
exports.setupProject = () => {
showBanner();
configFileExists();

Expand All @@ -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})

0 comments on commit 1978efd

Please sign in to comment.