this is here instead of utilities to prevent a require-loop when files that utilties requires need settings
492215
function matchKey(needle, obj, caseInsensitive) {
	needle = (caseInsensitive) ? needle.toLowerCase() : needle;
	for (let key in obj) {
		let keyCopy = (caseInsensitive) ? key.toLowerCase() : key;

		if (keyCopy === needle) {
			//return the original
			return key;
		}
	}

	return null;
}
395715
def resolve_requires
      relative_require_dir = @config_dir || Dir.pwd
      Array(@hash['require']).each do |r|
        if r.start_with?('.')
          require File.join(relative_require_dir, r)
        else
          require r
        end
      end
    end
303763
function requireAll(schemaDir, options, callback) {
  debug("loading schemas");
  if (!callback) {
    callback = options;
    options = {};
  }
  const opts = _.assign({
    extensions: ["json"],
  }, options);

  let files;
  try {
    files = fs.readdirSync(schemaDir);
  } catch(errReaddir) {
    return callback(errReaddir);
  }

  let schemas = [];

  for (let index = 0; index < files.length; index++) {
    const file = files[index];
    const ext = path.extname(file).slice(1);

    if (opts.extensions.indexOf(ext) === -1) {
      continue;
    }

    const abspath = path.join(schemaDir, file);
    let schema;

    // try load the schema! If it fails, stop immediately
    try {
      schema = require(abspath);
    } catch (errRequire) {
      return callback(errRequire);
    }

    schema.filepath = abspath;
    schemas.push(schema);
  }

  return callback(null, schemas);
}
540367
function requireJslint(jslintFileName) {
    /*jslint stupid: true */// JSLint doesn't like "*Sync" functions, but in this require-like function async would be overkill
    var jslintCode = bufferToScript(
        fs.readFileSync(
            path.join(__dirname, jslintFileName)
        )
    );
    /*jslint stupid: false */

    var sandbox = {};
    vm.runInNewContext(jslintCode, sandbox, jslintFileName);
    return sandbox.JSLINT;
}
881760
function enableModuleReplacement(opts) {
  // TODO: use proxy here instead of just monkey-patching so all furure extensions are tracked automatically
  const savedExtensions = Module._extensions;
  const _extensions = {};
  Object.keys(savedExtensions).forEach(extension => {
    _extensions[extension] = function(module, filename) {
      addHMRHooks(module);
      savedExtensions[extension](module, filename);
    };
  });

  Module._extensions = _extensions;

  // module is changed, which dependency needs to be reloaded?
  function collectDependencies(module) {
    let paths = [];
    function pathsToAcceptingModules(path, root) {
      const requiredMe = parents[root.filename];
      if (module.hot._selfAccepted) {
        paths.push(path.concat(root.filename));
        return;
      }
      if (module.hot._selfDeclined) {
        return;
      }
      for (let next in requiredMe) {
        let parentHotRuntime = requiredMe[next].hot;
        if (parentHotRuntime._acceptedDependencies[root.filename]) {
          paths.push(path.concat(root.filename));
          continue;
        }
        if (parentHotRuntime._declinedDependencies[root.filename]) {
          continue;
        }
        pathsToAcceptingModules(path.concat(root.filename), requiredMe[next]);
      }
    }
    pathsToAcceptingModules([], module);
    return paths;
  }

  opts = opts || {};
  function ignore(path) {
    if (isBuiltinModule(path)) {
      return true;
    }
    if (typeof opts.ignore === 'function') {
      return opts.ignore(path);
    }
    if (opts.ignore instanceof RegExp) {
      return !!opts.ignore.exec(path);
    }
  }

  const watching = {};
  function startWatching(path) {
    if (ignore(path)) {
      return;
    }
    if (watching[path]) {
      return;
    }
    watching[path] = watch(path, { persistent: false }, function(eventType, filename) {
      const oldModule = require.cache[path];

      const deps = oldModule ? collectDependencies(oldModule) : [];
      const reloaded = {};

      for (let d = 0; d < deps.length; ++d) {
        for (let l = 0; l < deps[d].length; ++l) {
          const path = deps[d][l];
          if (reloaded[path]) {
            continue;
          }
          reloaded[path] = true;
          const oldModule = require.cache[path];
          if (oldModule.hot._disposeHandlers) {
            oldModule.hot._disposeHandlers.forEach(h => h());
          }
          const newModule = new Module(path, oldModule.parent);
          addHMRHooks(newModule);
          try {
            newModule.load(path);
            require.cache[path] = newModule;
            const ps = parents[path];
            for (parentPath in ps) {
              let parent = require.cache[parentPath];
              if (parent.hot._acceptedDependencies[path]) {
                // TODO: try/catch here?
                parent.hot._acceptedDependencies[path](path);
              }
            }
          } catch (e) {
            console.log(e);
          }
        }
      }
    });
  }

  // monkey-patch require
  const originalRequire = Module.prototype.require;
  const originalLoad = Module._load;
  const originalCompile = Module.prototype._compile;

  const parents = {};
  Module._load = function(request, parent, isMain) {
    const requirePath = Module._resolveFilename(request, parent);
    if (ignore(requirePath)) {
      return originalLoad(request, parent, isMain);
    }

    startWatching(requirePath);
    const parentPath = parent && parent.filename;
    const myParents = parents[requirePath];
    if (parentPath) {
      if (!myParents) {
        var p = {};
        p[parentPath] = parent;
        parents[requirePath] = p;
      } else {
        myParents[parentPath] = parent;
      }
    }
    return originalLoad(request, parent, isMain);
  };

  if (module.parent) {
    if (!module.parent.hot) {
      addHMRHooks(module.parent);
    }
  }

  function addHMRHooks(module) {
    const resolve = name => {
      return Module._resolveFilename(name, module);
    };
    // copied directly from webpack HMR
    // https://github.com/webpack/webpack/blob/0257f6c6e41255cf26230c099fb90140f1f0e0bb/lib/HotModuleReplacement.runtime.js#L77
    var hot = {
      // private stuff
      _acceptedDependencies: {},
      _declinedDependencies: {},
      _selfAccepted: false,
      _selfDeclined: false,
      _disposeHandlers: [],
      // _main: hotCurrentChildModule !== moduleId,

      // Module API
      active: true,
      accept: function(dep, callback) {
        if (typeof dep === 'undefined') hot._selfAccepted = true;
        else if (typeof dep === 'function') hot._selfAccepted = dep;
        else if (typeof dep === 'object')
          for (var i = 0; i < dep.length; i++)
            hot._acceptedDependencies[resolve(dep[i])] = callback || function() {};
        else hot._acceptedDependencies[resolve(dep)] = callback || function() {};
      },
      decline: function(dep) {
        if (typeof dep === 'undefined') hot._selfDeclined = true;
        else if (typeof dep === 'object')
          for (var i = 0; i < dep.length; i++) hot._declinedDependencies[resolve(dep[i])] = true;
        else hot._declinedDependencies[resolve(dep)] = true;
      },
      dispose: function(callback) {
        hot._disposeHandlers.push(callback);
      },
      addDisposeHandler: function(callback) {
        hot._disposeHandlers.push(callback);
      },
      removeDisposeHandler: function(callback) {
        var idx = hot._disposeHandlers.indexOf(callback);
        if (idx >= 0) hot._disposeHandlers.splice(idx, 1);
      }
      /*
      // TODO: Management API
      check: hotCheck,
      apply: hotApply,

      status: function(l) {
        if (!l) return hotStatus;
        hotStatusHandlers.push(l);
      },
      addStatusHandler: function(l) {
        hotStatusHandlers.push(l);
      },
      removeStatusHandler: function(l) {
        var idx = hotStatusHandlers.indexOf(l);
        if (idx >= 0) hotStatusHandlers.splice(idx, 1);
      }

      //inherit from previous dispose call
      data: hotCurrentModuleData[moduleId]
    */
    };
    module.hot = hot;
  }
}
648763
function(module) {
			if (!module) {
				return;
			}

			var file = fileByModules(module);
			Array.prototype.push.apply(seen, file.modules);
			file.requires.forEach(function(module) {
				// Ignore resoled modules and dependencies in own file
				if((_.indexOf(resolved, module) < 0) &&
				   (_.indexOf(file.modules, module) < 0)) {
					// Catch circular dependencies
					if(_.indexOf(seen, module) < 0) {
						resolve(module);
					}
					else {
						grunt.fail.fatal('Circular dependency detected:\n\t' +
						                 file.modules.join(', ') + ' depend on ' +
						                 module, 1);
					}
				}
			});
			Array.prototype.push.apply(resolved, file.modules);
		}
1218104
function _requireModule(rootPath, name) {
  let modulePath = _normalizeRequire(rootPath, name),
    moduleRes;
  try {
    moduleRes = require(modulePath);
  } catch (e) {
    if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf(name) !== -1) {
      try {
        moduleRes = require(name);
      } catch (e) {
        if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf(name) !== -1) {
          throw "NOT_FOUND";
        }
        throw e;
      }
    } else {
      throw e;
    }
  }
  return moduleRes;
}
1110207
function (moduleName, modulePath, contents) {
					if (contents.indexOf("require(") < 0) { return contents; }
					if (modules.indexOf(moduleName) < 0) { return contents; }
					var start = "", end = "";
					layers.forEach(function (l) {
						start += "require([\"" + l.name + "\"], function () {\n";
						end += "\n});";
					});
					return contents.replace("require(", start + "require(") + end;
				}
433451
def with_file_utils(&block)
      Module.new do
        include Mustermann::FileUtils
        define_method(:f, &block)
        private(:f)
        extend self
      end
    end
179076
function define (File, utils) {
  const { debug, error, strong } = utils.cnsl;
  const { sourceMapCommentStrip } = utils.string;

  return class TYPESCRIPTFile extends File {
    /**
     * Compile file contents
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Array} ignoredFiles
     *  - {Boolean} helpers
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     * @returns {null}
     */
    compile (buildOptions, fn) {
      try {
        const compilerOptions = Object.assign(
          this.hasMaps ? { sourceMap: true, inlineSourceMap: false } : {},
          DEFAULT_COMPILER_OPTIONS,
          (this.options.pluginOptions.typescript && this.options.pluginOptions.typescript.compilerOptions) || {}
        );
        const options = {
          fileName: this.relpath,
          compilerOptions
        };
        const result = ts.transpileModule(this.content, options);

        this.setContent(sourceMapCommentStrip(result.outputText));
        if (result.sourceMapText) this.setMap(result.sourceMapText);
        debug(`compile: ${strong(this.relpath)}`, 4);
      } catch (err) {
        if (!this.options.runtimeOptions.watch) return fn(err);
        error(err, 4, false);
      }
      fn();
    }
  };
}
743855
function enableEnvConfig (grunt, opts) {
    var options = opts || {};
    var cacheConfig = options.cache;

    var getRaw = grunt.config.getRaw;

    grunt.config.getRaw = function getRawWrapper (prop) {
        if (prop) {
            prop = grunt.config.getPropString(prop);

            var required = propRequire(prop, /^\$require\.([a-z0-9_$]+(?:\.[a-z0-9_$]+)*)$/i);
            if (required) {
                return required;
            } else {
                return preprocessForEach(prop.replace(/([^\\])\./g, '$1\u000E').split('\u000E'), function preprocessEach (obj) {
                    // when not match the `$require` pattern, behave as `grunt.config.getRaw`
                    if (typeof obj === 'string' || obj instanceof String) {
                        var required = propRequire(obj, /^<%=\s*\$require\.([a-z0-9_$]+(?:\.[a-z0-9_$]+)*)\s*%>$/i);
                        // recursively template requiring is not supported
                        obj = required ? required : obj;
                    }

                    return obj;
                });
            }
        }

        return getRaw.apply(this, arguments);
    };

    function preprocessForEach (props, fn) {
        var parent = grunt.config.data
          , obj
          , eachProp;

        while ((eachProp = props.shift()) !== undefined && eachProp.length) {
            obj = parent[eachProp];
            if (eachProp in parent) {
                obj = fn.call(this, obj, parent);
                if (cacheConfig) {
                    parent[eachProp] = obj;
                }

                parent = obj;
            }

            if (typeof obj !== 'object') {
                break;
            }
        }

        return obj;
    }

    grunt.template.env = function (env) {
        if (typeof env !== 'string' && !(env instanceof String)) throw new TypeError('template.env expects string formated property');

        var obj = process.env;
        env.replace(/([^\\])\./g, '$1\u000E').split('\u000E').forEach(function (prop) {
            obj = obj[prop];
        });

        return obj;
    };

    grunt.template.through = function (obj) {
        if (typeof obj === 'object') {
            return JSON.stringify(obj);
        }

        return obj;
    };

    function propRequire (prop, regExpr) {
        var matched = prop.match(regExpr);
        if (matched) {
            var path = grunt.config.get(matched[1]);
            grunt.verbose.writeln('$require:' + path);
            return require(path);
        }
    }
}
779254
function () {
    var start = Date.now();
    bundler.bundle()
      .on('error', gutil.log)
      .pipe(source(options.name))
      .pipe(gulpif(options.uglify, streamify(uglify())))
      .pipe(gulp.dest(options.dest))
      .pipe(notify(function () {

        // Fix for requirejs
        var fs = require('fs');
        var file = fs.readFileSync(options.dest + '/' + options.name).toString();
        file = file.replace('define([],e)', 'define(["react"],e)');
        fs.writeFileSync(options.dest + '/' + options.name, file);

        console.log('Built in ' + (Date.now() - start) + 'ms');

      }));

  }
557228
function define (File, utils) {
  const { debug, error, strong } = utils.cnsl;

  return class STYLUSFile extends File {
    /**
     * Constructor
     * @param {String} id
     * @param {String} filepath
     * @param {Object} options
     *  - {Object} caches
     *  - {Object} fileExtensions
     *  - {Function} fileFactory
     *  - {Object} globalAliases
     *  - {Array} npmModulepaths
     *  - {Object} pluginOptions
     *  - {Object} runtimeOptions
     */
    constructor (id, filepath, options) {
      super(id, filepath, options);

      this.workflows.writeable = WORKFLOW_WRITEABLE;
    }

    /**
     * Compile file contents
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Array} ignoredFiles
     *  - {Boolean} helpers
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    compile (buildOptions, fn) {
      const style = stylus(this.content)
        .set('filename', this.relpath)
        // Gather all source directories
        .set('paths', this.options.fileCache.getDirs());

      if (this.hasMaps) style.set('sourcemap', { comment: false });
      if (this.options.pluginOptions.stylus) {
        for (const option in this.options.pluginOptions.stylus) {
          style.set(option, this.options.pluginOptions.stylus[option]);
        }
      }

      style.render((err, css) => {
        if (err) {
          if (!this.options.runtimeOptions.watch) return fn(err);
          error(err, 4, false);
        }

        this.setContent(css);
        if (style.sourcemap) this.setMap(style.sourcemap);
        debug(`compile: ${strong(this.relpath)}`, 4);
        fn();
      });
    }
  };
}
340777
function readRequireConfig( file ) {
   'use strict';
   var config = fs.readFileSync( file );
   /*jshint -W054*/
   var evaluate = new Function( 'var window = this;' + config + '; return require || window.require;' );
   return evaluate.call( {} );
}
988370
function (is_ignore_errors, opt_config_filename) {

		var self = this;

		var config_paths = [];
		if (opt_config_filename) {
			config_paths.push(opt_config_filename);
		} else {
			// root of dependence source directory
			config_paths.push('./config.json');
			// root of denhub-device directory
			config_paths.push(__dirname + '/../config.json');
		}

		var config_file = null;
		for (var i = 0, l = config_paths.length; i < l; i++) {
			try {
				config_file = require('fs').readFileSync(config_paths[i]);
			} catch (e) {
				continue;
			}
			if (config_file) break;
		}

		if (!config_file && !is_ignore_errors) {
			console.log(colors.bold.red('Error: Could not read the configuration file.'));
			console.log(config_paths.join('\n'));
			console.log(colors.bold('If you never created it, please try the following command:'));
			console.log('$ denhub-device-generator init\n');
			process.exit(255);
		}

		var config = {};
		if (config_file) {
			try {
				config = JSON.parse(config_file.toString());
			} catch (e) {
				if (!is_ignore_errors) throw e;
			}
		}

		config.commands = self._getLocalCommands(is_ignore_errors) || null;

		return config;

	}
28789
function require(...names) {
		const unknown = names.filter(name => !options[name]);
		if (unknown.length > 0) {
			throw new MrmUndefinedOption(`Required config options are missed: ${unknown.join(', ')}.`, {
				unknown,
			});
		}
		return config;
	}
656495
function requireContext({ references, state, babel: { types: t } }) {
  if (process.env.NODE_ENV === 'test') {
    references.default.forEach(path =>
      path.parentPath.replaceWith(
        t.callExpression(t.identifier("require('require-context.macro/context')"), [
          t.identifier('__dirname'),
          ...path.parent.arguments,
        ])
      )
    );
  } else {
    references.default.forEach(path =>
      path.parentPath.replaceWith(
        t.callExpression(t.identifier('require.context'), [...path.parent.arguments])
      )
    );
  }
}