Skip to content

Commit

Permalink
bug(server): the server crashes if the root directory doesn't exist
Browse files Browse the repository at this point in the history
Fixed

Fixes #81
  • Loading branch information
sumitparakh committed Dec 14, 2018
1 parent b5639ec commit 387bbde
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/klingon-server/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const pty = require('node-pty');
const { spawn } = require('child_process');
const bodyParser = require('body-parser');
const guard = require('./core/guard');
const fs = require('fs');

app.use(cors());
app.use(bodyParser.json()); // to support JSON-encoded bodies
Expand Down Expand Up @@ -57,6 +58,10 @@ app.ws('/cli', (ws, res) => {
const flags = msg.stdin.split(' ');
console.log('<<<', flags);

if(msg.dir && !fs.existsSync(msg.dir)) {
fs.mkdirSync(msg.dir);
}

const child = spawn(os.platform() === 'win32' ? 'ng.cmd' : 'ng', flags, {
cwd: msg.dir || os.homedir(),
env: process.env
Expand Down

0 comments on commit 387bbde

Please sign in to comment.