From 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 28 May 2017 00:38:50 +0200 Subject: add linting (and some initial fixes) --- node_modules/hullabaloo-config-manager/index.js | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 node_modules/hullabaloo-config-manager/index.js (limited to 'node_modules/hullabaloo-config-manager/index.js') diff --git a/node_modules/hullabaloo-config-manager/index.js b/node_modules/hullabaloo-config-manager/index.js new file mode 100644 index 000000000..4e10228e7 --- /dev/null +++ b/node_modules/hullabaloo-config-manager/index.js @@ -0,0 +1,60 @@ +'use strict' + +const path = require('path') + +const cloneDeep = require('lodash.clonedeep') + +const collector = require('./lib/collector') +const currentEnv = require('./lib/currentEnv') +const ResolvedConfig = require('./lib/ResolvedConfig') +const Verifier = require('./lib/Verifier') + +function createConfig (options) { + if (!options || !options.options || !options.source) { + throw new TypeError("Expected 'options' and 'source' options") + } + if (typeof options.options !== 'object' || Array.isArray(options.options)) { + throw new TypeError("'options' must be an actual object") + } + + const source = options.source + const dir = options.dir || path.dirname(source) + const hash = options.hash || null + const json5 = options.json5 !== false + const babelOptions = cloneDeep(options.options) + + return new collector.Config(dir, null, hash, json5, babelOptions, source) +} +exports.createConfig = createConfig + +exports.currentEnv = currentEnv + +function fromConfig (baseConfig, options) { + options = options || {} + return collector.fromConfig(baseConfig, options.cache) + .then(chains => new ResolvedConfig(chains, options.cache)) +} +exports.fromConfig = fromConfig + +function fromDirectory (dir, options) { + options = options || {} + return collector.fromDirectory(dir, options.cache) + .then(chains => chains && new ResolvedConfig(chains, options.cache)) +} +exports.fromDirectory = fromDirectory + +function prepareCache () { + return { + dependencyHashes: new Map(), + fileExistence: new Map(), + files: new Map(), + pluginsAndPresets: new Map(), + sourceHashes: new Map() + } +} +exports.prepareCache = prepareCache + +function restoreVerifier (buffer) { + return Verifier.fromBuffer(buffer) +} +exports.restoreVerifier = restoreVerifier -- cgit v1.2.3