Skip to content
Permalink
Browse files

Add check for dependencies on startup

  • Loading branch information...
agrawalarpit14 committed Mar 28, 2019
1 parent aa895ab commit c7c7de80d08948d9cf23e62e4df6467bb9c51ffb
Showing with 143 additions and 177 deletions.
  1. +4 −3 app.js
  2. +11 −30 frontend/package-lock.json
  3. +22 −0 lib/startup/validateDependencies.js
  4. +105 −144 package-lock.json
  5. +1 −0 package.json
7 app.js
@@ -1,3 +1,4 @@
const server = require('./server')

server.start()
require('./lib/startup/validateDependencies')().then(() => {
const server = require('./server')
server.start()
})

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,22 @@
const dependencyCheck = require('check-dependencies')
const logger = require('../logger')
const colors = require('colors/safe')

const validateDependencies = async ({ exitOnFailure = true } = {}) => {
await dependencyCheck().then((val) => {
if (val.depsWereOk === true) {
logger.info(`All dependencies are satisfied (${colors.green('OK')})`)
} else {
logger.warn(`Dependencies are not rightly satisfied (${colors.red('NOT OK')})`)
for (var i in val.error) {
console.log(val.error[i])
}
logger.error(colors.red('Exiting due to unsatisfied dependencies!'))
process.exit(1)
}
}, () => {
logger.error(colors.red('Exiting due to error in dependency check! '))
})
}

module.exports = validateDependencies

0 comments on commit c7c7de8

Please sign in to comment.
You can’t perform that action at this time.