UNPKG

veendor

Version:

a tool for stroing your npm dependencies in arbitraty storage

40 lines (39 loc) 1.38 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const validateConfig_1 = __importDefault(require("./validateConfig")); const path_1 = __importDefault(require("path")); function resolveConfig(explicitConfig) { global.VEENDOR_VERSION = require('../package.json').version; return new Promise(resolve => { let config; let configLocations = ['.veendor.js', '.veendor.json']; if (explicitConfig) { configLocations = [explicitConfig]; } for (const location of configLocations) { try { config = require(path_1.default.resolve(process.cwd(), location)); } catch (e) { if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf(location) !== -1) { continue; } throw e; } } if (!config) { console.error('Config file not found'); process.exit(1); } validateConfig_1.default(config).then(config => { resolve(config); }, error => { console.error(error.message); process.exit(1); }); }); } exports.default = resolveConfig;