UNPKG

apiconnect-config

Version:

Configuration module IBM API Connect Developer Toolkit

50 lines (42 loc) 1.69 kB
/********************************************************* {COPYRIGHT-TOP} *** * Licensed Materials - Property of IBM * 5725-Z22, 5725-Z63, 5725-U33, 5725-Z63 * * (C) Copyright IBM Corporation 2016, 2017 * * All Rights Reserved. * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. ********************************************************** {COPYRIGHT-END} **/ // Node module: apiconnect-config 'use strict'; module.exports = loadConfig; var Config = require('./config'); var debug = require('debug')('apiconnect-config:lib:loader'); var project = require('apiconnect-project'); /** * Load config info. If within a supported project, also load project configuration. * @param {string} [baseDir] directory to load from. If not set, tried to load cwd. * @param {object} [options] config options. * @param {boolean} [options.shouldParseUris] Indicates if URIs in values should be parsed and returned as objects in * @param {boolean} [options.loadFromEnv] Indicated if process.env should also be searched when getting values. Env will * override project and user level configuration. * {@see Config@get} calls. * @return {Config} */ function loadConfig(baseDir, options) { if (typeof baseDir === 'object') { options = baseDir; baseDir = null; } baseDir = baseDir || process.cwd(); if (!options) { options = {}; } var info = project.inspectPath(baseDir); if (info.type === 'project' || info.type === 'directory') { options.projectDir = info.basePath; } debug('baseDir %s, info: %j, config opts: %j', baseDir, info, options); return new Config(options); };