diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/liftoff/lib | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) | |
download | wallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz |
add node_modules to address #4364
Diffstat (limited to 'node_modules/liftoff/lib')
-rw-r--r-- | node_modules/liftoff/lib/build_config_name.js | 17 | ||||
-rw-r--r-- | node_modules/liftoff/lib/file_search.js | 14 | ||||
-rw-r--r-- | node_modules/liftoff/lib/find_config.js | 25 | ||||
-rw-r--r-- | node_modules/liftoff/lib/find_cwd.js | 18 | ||||
-rw-r--r-- | node_modules/liftoff/lib/parse_options.js | 35 | ||||
-rw-r--r-- | node_modules/liftoff/lib/register_loader.js | 25 | ||||
-rw-r--r-- | node_modules/liftoff/lib/silent_require.js | 5 |
7 files changed, 139 insertions, 0 deletions
diff --git a/node_modules/liftoff/lib/build_config_name.js b/node_modules/liftoff/lib/build_config_name.js new file mode 100644 index 000000000..b83e18508 --- /dev/null +++ b/node_modules/liftoff/lib/build_config_name.js @@ -0,0 +1,17 @@ +module.exports = function (opts) { + opts = opts || {}; + var configName = opts.configName; + var extensions = opts.extensions; + if (!configName) { + throw new Error('Please specify a configName.'); + } + if (configName instanceof RegExp) { + return [configName]; + } + if (!Array.isArray(extensions)) { + throw new Error('Please provide an array of valid extensions.'); + } + return extensions.map(function (ext) { + return configName + ext; + }); +}; diff --git a/node_modules/liftoff/lib/file_search.js b/node_modules/liftoff/lib/file_search.js new file mode 100644 index 000000000..76dadd674 --- /dev/null +++ b/node_modules/liftoff/lib/file_search.js @@ -0,0 +1,14 @@ +const findup = require('findup-sync'); + +module.exports = function (search, paths) { + var path; + var len = paths.length; + for (var i = 0; i < len; i++) { + if (path) { + break; + } else { + path = findup(search, {cwd: paths[i], nocase: true}); + } + } + return path; +}; diff --git a/node_modules/liftoff/lib/find_config.js b/node_modules/liftoff/lib/find_config.js new file mode 100644 index 000000000..71c3f077d --- /dev/null +++ b/node_modules/liftoff/lib/find_config.js @@ -0,0 +1,25 @@ +const fs = require('fs'); +const path = require('path'); +const fileSearch = require('./file_search'); + +module.exports = function (opts) { + opts = opts || {}; + var configNameSearch = opts.configNameSearch; + var configPath = opts.configPath; + var searchPaths = opts.searchPaths; + // only search for a config if a path to one wasn't explicitly provided + if (!configPath) { + if (!Array.isArray(searchPaths)) { + throw new Error('Please provide an array of paths to search for config in.'); + } + if (!configNameSearch) { + throw new Error('Please provide a configNameSearch.'); + } + configPath = fileSearch(configNameSearch, searchPaths); + } + // confirm the configPath exists and return an absolute path to it + if (fs.existsSync(configPath)) { + return path.resolve(configPath); + } + return null; +}; diff --git a/node_modules/liftoff/lib/find_cwd.js b/node_modules/liftoff/lib/find_cwd.js new file mode 100644 index 000000000..2a029b972 --- /dev/null +++ b/node_modules/liftoff/lib/find_cwd.js @@ -0,0 +1,18 @@ +const path = require('path'); + +module.exports = function (opts) { + if (!opts) { + opts = {}; + } + var cwd = opts.cwd; + var configPath = opts.configPath; + // if a path to the desired config was specified + // but no cwd was provided, use configPath dir + if (typeof configPath === 'string' && !cwd) { + cwd = path.dirname(path.resolve(configPath)); + } + if (typeof cwd === 'string') { + return path.resolve(cwd); + } + return process.cwd(); +}; diff --git a/node_modules/liftoff/lib/parse_options.js b/node_modules/liftoff/lib/parse_options.js new file mode 100644 index 000000000..ab416b520 --- /dev/null +++ b/node_modules/liftoff/lib/parse_options.js @@ -0,0 +1,35 @@ +const extend = require('extend'); + +module.exports = function (opts) { + var defaults = { + extensions: { + '.js': null, + '.json': null + }, + searchPaths: [] + }; + if (!opts) { + opts = {}; + } + if (opts.name) { + if (!opts.processTitle) { + opts.processTitle = opts.name; + } + if (!opts.configName) { + opts.configName = opts.name + 'file'; + } + if (!opts.moduleName) { + opts.moduleName = opts.name; + } + } + if (!opts.processTitle) { + throw new Error('You must specify a processTitle.'); + } + if (!opts.configName) { + throw new Error('You must specify a configName.'); + } + if (!opts.moduleName) { + throw new Error('You must specify a moduleName.'); + } + return extend(defaults, opts); +}; diff --git a/node_modules/liftoff/lib/register_loader.js b/node_modules/liftoff/lib/register_loader.js new file mode 100644 index 000000000..2b5f4cb75 --- /dev/null +++ b/node_modules/liftoff/lib/register_loader.js @@ -0,0 +1,25 @@ +const rechoir = require('rechoir'); +const isString = require('lodash.isstring'); + +module.exports = function(eventEmitter, extensions, configPath, cwd) { + extensions = extensions || {}; + + if (!isString(configPath)) { + return; + } + + var autoloads = rechoir.prepare(extensions, configPath, cwd, true); + if (autoloads instanceof Error) { + autoloads = autoloads.failures; + } + + if (Array.isArray(autoloads)) { + autoloads.forEach(function (attempt) { + if (attempt.error) { + eventEmitter.emit('requireFail', attempt.moduleName, attempt.error); + } else { + eventEmitter.emit('require', attempt.moduleName, attempt.module); + } + }); + } +}; diff --git a/node_modules/liftoff/lib/silent_require.js b/node_modules/liftoff/lib/silent_require.js new file mode 100644 index 000000000..7b4dfe4e5 --- /dev/null +++ b/node_modules/liftoff/lib/silent_require.js @@ -0,0 +1,5 @@ +module.exports = function (path) { + try { + return require(path); + } catch (e) {} +}; |