/*
Creates a karma configuration.

@param {string} sourceFile The source file to test
@param {array} loaders An array of loaders to apply to the source file.
422788
function createConf(sourceFile, loaders) {

    var allLoaders = [];
    var testFilesPattern = 'src/**/*.test.js';

    if (loaders) {
        allLoaders.concat(loaders);
    }

    // Return a new instance each time.
    var conf = {

        browsers: ['PhantomJS'],

        files: [
            // https://github.com/webpack/style-loader/issues/31
            'node_modules/phantomjs-polyfill/bind-polyfill.js',

            testFilesPattern
        ],

        frameworks: ['jasmine'],

        plugins: [
            karmaWebpackPlugin,
            'karma-jasmine',
            'karma-phantomjs-launcher'
        ],

        preprocessors: {},

        reporters: [
            'dots'
        ],

        webpack: {
            module: {
                loaders: allLoaders
            },
            resolve: {
                alias: {}
            }
        },

        webpackMiddleware: {
            noInfo: true
        }

    };

    // Resolve to the correct file for testing.
    conf.webpack.resolve.alias[webpackConfig.library.projectName] =
        path.join(__dirname, sourceFile);

    conf.preprocessors[testFilesPattern] = ['webpack'];

    return conf;
}
1354744
function framework(emitter, config, logger) {

    log = logger.create('framework.browserify');

    if (!bundleFile) {
      bundleFile = new BundleFile();
    }

    bundleFile.touch();
    log.debug('created browserify bundle: %s', bundleFile.location);

    b = createBundle(config);

    // TODO(Nikku): hook into karma karmas file update facilities
    // to remove files from the bundle once karma detects the deletion

    // hook into exit for cleanup
    emitter.on('exit', function(done) {
      log.debug('cleaning up');

      if (b.close) {
        b.close();
      }

      bundleFile.remove();
      done();
    });


    // add bundle file to the list of files defined in the
    // configuration. be smart by doing so.
    addBundleFile(bundleFile, config);

    return b;
  }
1239847
function loadNunjucks(filtersModule) {
  if (fs.existsSync(filtersModule)) {
    try {
      const filters = require(filtersModule);
      nj = templater.loadNjEnv(filters.sync, filters.async);
    } catch (e) {
      console.log('Failed to load Nunjucks environment: ', e);
      process.exit(1);
    }
  }
  else {
    try {
      nj = templater.loadNjEnv();
    } catch (e) {
      console.log('Failed to load Nunjucks environment: ', e);
      process.exit(1);
    }
  }
}
248480
public function loadConfiguration(ConfigurationLoader $loader, array $params = [])
	{
		try
		{
			$data = $loader->findLoader($this->source)->load($this->source, $params);
			
			return new Configuration($this->createBase($data));
		}
		catch(\Exception $e)
		{
			throw new ConfigurationLoadingException(sprintf('Unable to load config from source "%s"', $this->source->getPathname()), 0, $e);
		}
	}
225756
function createLoader(handlers) {
  var handlerMap = new Map(Object.keys(handlers).map(function (key) {
    return [key, handlers[key]];
  }));
  handlers = undefined;

  return function (state, data) {
    var keys = Object.keys(data);
    return Promise.all(keys.map(function (key) {
      var handler = handlerMap.get(key);

      return handler(state, data[key]);
    })).then(function (results) {
      var data = Object.create(null);
      results.forEach(function (result, index) {
        data[keys[index]] = result;
      });
      return data;
    });
  };
}
1139300
function load(method, config) {
  return function(patterns, options) {
    var opts = mergeOptions(this, config, options);
    var loader = createLoader(opts, this[method]);
    return loader.apply(this, arguments);
  };
}
1135810
function define (HTMLFile, utils) {
  const { callable } = utils;
  const { debug, error, strong } = utils.cnsl;
  const { regexpEscape, uniqueMatch } = utils.string;

  return class HANDLEBARSFile extends HTMLFile {
    /**
     * 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;
    }

    /**
     * Parse file contents for dependency references
     * @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)
     */
    parse (buildOptions, fn) {
      super.parse(buildOptions, (err) => {
        if (err) return fn(err);
        // Add sidecar json file
        const sidecarData = super.parseSidecarDependency();
        // Parse includes
        let matches = uniqueMatch(this.content, RE_INCLUDE)
          .map((match) => {
            match.id = match.match;
            return match;
          });

        if (sidecarData) matches.push(sidecarData);
        super.addDependencies(matches, buildOptions);
        fn();
      });
    }

    /**
     * Inline css/img/js dependency content
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Boolean} helpers
     *  - {Array} ignoredFiles
     *  - {Boolean} import
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    inlineInlineable (buildOptions, fn) {
      // Only dependencies
      parallel([...this.getAllDependencies()].reduce((inlineable, file) => {
        if (file instanceof HANDLEBARSFile && this.dependencyReferences.length) {
          inlineable.push(callable(file, 'inline', buildOptions));
        }
        return inlineable;
      }, []), fn);
    }

    /**
     * Inline partials content
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Boolean} helpers
     *  - {Array} ignoredFiles
     *  - {Boolean} import
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    inlineIncludes (buildOptions, fn) {
      [...this.getAllDependencies(), this].forEach((file) => {
        if (file instanceof HANDLEBARSFile && file.dependencyReferences.length) {
          let content = file.content;

          file.dependencyReferences.forEach((reference) => {
            if (reference.file && reference.context) {
              content = content.replace(new RegExp(regexpEscape(reference.context), 'g'), reference.file.content);
            }
          });

          file.setContent(content);
        }
      });
      fn();
    }

    /**
     * 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 options = Object.assign({}, DEFAULT_OPTIONS, this.options.pluginOptions.handlebars);
        const template = handlebars.compile(this.content, options);

        this.setContent(template(this.findSidecarDependency()));
        debug(`compile: ${strong(this.relpath)}`, 4);
        fn();
      } catch (err) {
        if (!this.options.runtimeOptions.watch) return fn(err);
        error(err, 4, false);
      }
    }

    /**
     * Reparse file contents for dependency references
     * @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)
     */
    reparse (buildOptions, fn) {
      this.allDependencies = null;
      this.allDependencyReferences = null;
      this.dependencies = [];
      this.dependencyReferences = [];

      super.parse(buildOptions, fn);
    }
  };
}
41903
function processResult(loaderContext, resultPromise) {
  const { callback } = loaderContext;

  resultPromise
    .then(
      ({ css, map, imports }) => {
        imports.forEach(loaderContext.addDependency, loaderContext);
        return {
          // Removing the sourceMappingURL comment.
          // See removeSourceMappingUrl.js for the reasoning behind this.
          css: removeSourceMappingUrl(css),
          map: typeof map === 'string' ? JSON.parse(map) : map,
        };
      },
      (lessError) => {
        if (lessError.filename) {
          loaderContext.addDependency(lessError.filename);
        }
        throw formatLessError(lessError);
      }
    )
    .then(({ css, map }) => {
      callback(null, css, map);
    }, callback);
}
1032428
function (config) {
            if (isUrlOnWhitelist(config.url)) {
              numLoadings++;
              $rootScope.$emit('loaderShow', config.method);
            }

            return config || $q.when(config);
          }
283332
function reloadSources(names) {

    names = u.isArray(names) ? names :
           names ? [names] :
           u.keys(opts.source$);

    var results = [];

    u.each(names, function(name) {
      var source = opts.source$[name];
      if (source) {
        source._reloadFromSource = true;
        results.push(name);
      } else {
        results.push(log('reloadSources unknown source ' + name));
      }
    });

    generator.reload(); // throttled
    return results;
  }
1100279
function loadComponentFile (meta, key, filepath, messages) {
  const ext = path.extname(filepath).slice(1)
  const loader = fileLoaders[ext] || fileLoaders.DEFAULT

  return loader(meta, key, filepath, messages)
}
1245032
function(source){
    // this -> sourceInfo
    var merge = this.owner;
    var sourcesMap_ = merge.sourcesMap_;
    var dataset = resolveDataset(this, merge.updateDataset_, source, 'adapter', merge);
    var inserted;
    var deleted;
    var delta;

    if (this.dataset === dataset)
      return;

    if (dataset)
    {
      var count = (sourcesMap_[dataset.basisObjectId] || 0) + 1;
      sourcesMap_[dataset.basisObjectId] = count;
      if (count == 1)
      {
        merge.addDataset_(dataset);
        inserted = [dataset];
      }
    }

    if (this.dataset)
    {
      var count = (sourcesMap_[this.dataset.basisObjectId] || 0) - 1;
      sourcesMap_[this.dataset.basisObjectId] = count;
      if (count == 0)
      {
        merge.removeDataset_(this.dataset);
        deleted = [this.dataset];
      }
    }

    this.dataset = dataset;

    // build delta and fire event
    merge.applyRule();

    // fire sources changes event
    if (delta = getDelta(inserted, deleted))
    {
      var setSourcesTransaction = merge.sourceDelta_;
      if (setSourcesTransaction)
      {
        if (delta.inserted)
          delta.inserted.forEach(function(item){
            if (!arrayRemove(this.deleted, item))
              arrayAdd(this.inserted, item);
          }, setSourcesTransaction);

        if (delta.deleted)
          delta.deleted.forEach(function(item){
            if (!arrayRemove(this.inserted, item))
              arrayAdd(this.deleted, item);
          }, setSourcesTransaction);
      }
      else
      {
        merge.emit_sourcesChanged(delta);
      }
    }

    return delta;
  }
67735
function Blog(loader, options) {
    this.slugs = {};
    this.ids = {};
    this.posts = [];
    this.length = 0;
    options = options || {};
    if (typeof loader === 'string') {
        loader = new FileSystemLoader(loader, options);
    } else if (Array.isArray(loader)) {
        loader = new ArrayLoader(loader);
    }
    var self = this;
    loader.on('error', function (err) {
        self.emit('error', err);
    });
    loader.on('load', this.onLoad.bind(this));
    loader.on('new_post', this.onNewPost.bind(this));
    loader.on('updated_post', this.onUpdatedPost.bind(this));
    loader.on('removed_post', this.onRemovedPost.bind(this));
}
145505
async function create(sourcedir) {
	const target = join(sourcedir, FILENAME);
	const exists = await exist(target);

	const source = exists
		? target
		: join(__dirname, FILENAME)
	;

	const content = await readFile(source);
	await writeFile(primed, content.toString());

	return exists
		?	'Creating a new Dangerfile'
		: 'Creating a default Dangerfile'
	;
}
1223616
function Loader(options) {
  if (!(this instanceof Loader)) {
    return new Loader(options);
  }
  this.options = options || {};
  this.cache = this.options.helpers || {};
}
306667
function moduleExport(getters, constant) {
  utils.setESModule(this.exports);
  var entry = Entry.getOrCreate(this.id, this);
  entry.addGetters(getters, constant);
  if (this.loaded) {
    // If the module has already been evaluated, then we need to trigger
    // another round of entry.runSetters calls, which begins by calling
    // entry.runModuleGetters(module).
    entry.runSetters();
  }
}
261334
function(loader, name){
		var pkg = utils.pkg.findByName(loader, name.split("/")[0]);
		if(pkg) {
			var parsed = utils.moduleName.parse(name, pkg.name);
			parsed.version = pkg.version;
			if(!parsed.modulePath) {
				parsed.modulePath = utils.pkg.main(pkg);
			}
			return utils.moduleName.create(parsed);
		}
		return name;
	}