Acme.BookStore.HttpApi.Host/node_modules/matchdep/lib/matchdep.js

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*
 * matchdep
 * https://github.com/tkellen/node-matchdep
 *
 * Copyright (c) 2012 Tyler Kellen
 * Licensed under the MIT license.
 */

'use strict';

var micromatch = require('micromatch');
var findup = require('findup-sync');
var resolve = require('resolve').sync;
var stackTrace = require('stack-trace');
var path = require('path');

// export object
var matchdep = module.exports = {};

// Ensure configuration has the correct properties.
function loadConfig(config, props) {
  // The calling module's path. Unfortunately, because modules are cached,
  // module.parent is the FIRST calling module parent, not necessarily the
  // current one.
  var callerPath = path.dirname(stackTrace.get(loadConfig)[1].getFileName());

  // If no config defined, resolve to nearest package.json to the calling lib. If not found, throw an error.
  if (config == null) {
    config = findup('package.json', {cwd: callerPath});
    if (config == null) {
      throw new Error('No package.json found.');
    }
  }
  // If filename was specified with no path parts, make the path absolute so
  // that resolve doesn't look in node_module directories for it.
  else if (typeof config === 'string' && !/[\\\/]/.test(config)) {
    config = path.join(callerPath, config);
  }

  // If package is a string, try to require it.
  if (typeof config === 'string') {
    config = require(resolve(config, {basedir: callerPath}));
  }

  // If config is not an object yet, something is amiss.
  if (typeof config !== 'object') {
    throw new Error('Invalid configuration specified.');
  }

  // For all specified props, populate result object.
  var result = {};
  props.forEach(function(prop) {
    result[prop] = config[prop] ? Object.keys(config[prop]) : [];
  });
  return result;
}

// What config properties should each method search?
var methods = {
  filter: ['dependencies'],
后面还有 16 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。