Skip to content

Commit

Permalink
fix(general): added cli command
Browse files Browse the repository at this point in the history
  • Loading branch information
serge1peshcoff committed Dec 26, 2019
1 parent 05eae5b commit a2ba143
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const models = require('./models');
const { Sequelize, sequelize, authenticate } = require('./lib/sequelize');

global.authenticate = authenticate;
global.Sequelize = Sequelize;
global.sequelize = sequelize;

for (const key in models) {
global[key] = models[key]; // importing models as global
}

authenticate().catch((err) => {
/* eslint-disable-next-line no-console */
console.error('Error connecting to DB:', err.message);
process.quit(1);
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"db:setup": "sequelize db:drop; sequelize db:create; sequelize db:migrate",
"db:migrate": "sequelize db:migrate",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
"open-coverage": "open-cli coverage/lcov-report/index.html"
"open-coverage": "open-cli coverage/lcov-report/index.html",
"cli": "node --experimental-repl-await -r ./cli.js"
},
"husky": {
"hooks": {
Expand Down

0 comments on commit a2ba143

Please sign in to comment.