Skip to content

Commit

Permalink
small enchancements to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Nov 25, 2017
1 parent 06b7af2 commit 9849b32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function generateModelFiles() {

if (!fs.existsSync(`${memServerDirectory}/models/${modelFileName}.js`)) {
fs.writeFileSync(`${memServerDirectory}/models/${modelFileName}.js`, `import Model from 'memserver/model';
export default Model({
});`);
Expand All @@ -112,6 +112,10 @@ export default Model({
}

function openConsole() {
if (process.cwd().includes('memserver')) {
throw new Error(chalk.red('[MemServer CLI] You are in the memserver directory, go to the root of your project to start memserver console.'));
}

const MemServer = require('./lib/index.js');
const repl = require('repl');

Expand All @@ -136,5 +140,7 @@ function getMemServerDirectory() {
const targetIndex = cwd.lastIndexOf('memserver') + 9;

return cwd.slice(0, targetIndex);
} else if (fs.readdirSync('.').includes('memserver')) {
return `${cwd}/memserver`;
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"jsdom": "^11.3.0",
"pretender": "^1.6.0",
"qs": "^6.5.1",
"route-recognizer": "^0.3.3",
"rollup": "^0.50.0",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-virtual": "^1.0.1"
"rollup-plugin-virtual": "^1.0.1",
"route-recognizer": "^0.3.3"
},
"devDependencies": {
"cors": "^2.8.4",
Expand Down

0 comments on commit 9849b32

Please sign in to comment.