UNPKG

onions-node

Version:

onions-node backend

22 lines (20 loc) 680 B
const fs = require('fs') const path = require('path') module.exports = (config, projectRootPath) => { if (!fs.existsSync(path.join(projectRootPath, './package.json'))) { throw new Error('cannot found package.json of project!') } const configCheckMap = { port: 'cannot found key [port] in config file', project: 'cannot found key [project] in config file', env: 'cannot found key [env] in config file', dist: 'cannot found key [dist] in config file', logPath: 'cannot found key [logPath] in config file', } Object.keys(configCheckMap).forEach(key => { if (!config[key]) { throw new Error(configCheckMap[key]) } }) return true }