Processes a list of packages and concatenates their contents into a single object.

@name readPackages
@function
@param {Array} packages array of paths to package files
@return {Promise}
516837
function readPackages() {
  var packages = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];

  return Promise.all(packages.map(readPackage)).then(function (labels) {
    return labels.reduce(function (prev, curr) {
      return prev.concat(curr);
    });
  });
}
121639
function getPackagesTasks(baseTask) {
	var packages = getPackages();
	var tasks = [];

	for (index = 0; index < packages.length; ++index) {
	    tasks.push(baseTask + '.' + packages[index]);
	}

	return tasks;
}
508341
private void setPackages(DocEnv env, List<String> packages) {
        ListBuffer<PackageDocImpl> packlist = new ListBuffer<PackageDocImpl>();
        for (String name : packages) {
            PackageDocImpl pkg = env.lookupPackage(name);
            if (pkg != null) {
                pkg.isIncluded = true;
                packlist.append(pkg);
            } else {
                env.warning(null, "main.no_source_files_for_package", name);
            }
        }
        cmdLinePackages = packlist.toList();
    }
889640
function walkModules(dir, done) {

  var results = [];

  fs.readdir(dir, function(err, list) {
    if (err) return done(err);
    var pending = list.length;
    if (!pending) return done(null, results);

    list.forEach(function(file) {
      file = dir + path.sep + file;

      fs.stat(file, function(err, stat) {
        if (stat && stat.isDirectory()) {

          if (file.indexOf('node_modules') > -1) {
            walkModules(file, function(err, res) {
              results = results.concat(res);
              if (!--pending) done(null, results);
            });
          }
          else {
            if (!--pending) done(null, results);
          }

        } else {

          if (file.slice(-12) === 'package.json') {
            var parts = file.split(path.sep);
            if (parts[parts.length-3] === 'node_modules') {
              results.push(file);
            }
          }
          
          if (!--pending) done(null, results);
        }
      });
    });
  });
}
467041
public void process(String packageNames) {

		if (packageNames == null) {
			processPackage("", true);
			return;
		}

		String[] pkgs = packageNames.split(",");
		for (int i = 0; i < pkgs.length; i++) {

			String pkg = pkgs[i].trim().replace('.', '/');

			boolean recurse = false;
			if (pkg.endsWith("**")) {
				recurse = true;
				pkg = pkg.substring(0, pkg.length() - 2);
			} else if (pkg.endsWith("*")) {
				recurse = true;
				pkg = pkg.substring(0, pkg.length() - 1);
			}
			
			pkg = trimSlash(pkg);

			processPackage(pkg, recurse);
		}
	}
257680
function parsePackageJson(path) {
    return fs.readFile(path)
        .catch(function () {
            var err = new Error(common.i18n.t('errors.utils.parsepackagejson.couldNotReadPackage'));
            err.context = path;

            return Promise.reject(err);
        })
        .then(function (source) {
            var hasRequiredKeys, json, err;

            try {
                json = JSON.parse(source);

                hasRequiredKeys = json.name && json.version;

                if (!hasRequiredKeys) {
                    err = new Error(common.i18n.t('errors.utils.parsepackagejson.nameOrVersionMissing'));
                    err.context = path;
                    err.help = common.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://docs.ghost.org/api/handlebars-themes/'});

                    return Promise.reject(err);
                }

                return json;
            } catch (parseError) {
                err = new Error(common.i18n.t('errors.utils.parsepackagejson.themeFileIsMalformed'));
                err.context = path;
                err.help = common.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://docs.ghost.org/api/handlebars-themes/'});

                return Promise.reject(err);
            }
        });
}
1056475
def read_packages(reqs_file):
    
    for line in stream_file_lines(reqs_file):
        line = line.strip()
        if not line.startswith(('#', '--hash')):
            match = DEP_PATTERN.match(line)
            if match:
                package, version, marker = match.groups()
                yield Package(package.lower(), version, marker)
1062630
public static List<Class<?>> scanPackage(String... packages) throws IOException, ClassNotFoundException {
        List<Class<?>> list = new ArrayList<>();
        for (String pkg : packages) {
            list.addAll(getClasses(pkg));
        }
        return list;
    }
280712
function concat() {
    var observables = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        observables[_i] = arguments[_i];
    }
    return function (source) { return source.lift.call(_observable_concat__WEBPACK_IMPORTED_MODULE_0__["concat"].apply(void 0, [source].concat(observables))); };
}
1357822
public Application packages(String... packages) {
        if (scanPackages == null) {
            scanPackages = Sets.newHashSet();
        }
        Collections.addAll(scanPackages, packages);
        return this;
    }
824786
async function getSortedPackages() {
    // Support --scope and --ignore globs
    const {scope, ignore} = minimist(process.argv.slice(2));

    // Standard Lerna plumbing getting packages
    const packages = await getPackages(__dirname);
    const filtered = filterPackages(
        packages,
        scope,
        ignore,
        false
    );

    return batchPackages(filtered)
        .reduce((arr, batch) => arr.concat(batch), []);
}
60662
function concatPackage (pack, outDir, minified) {
  if (_.contains(concatedPkgs, path.basename(pack))) return;

  var bowerFile = 'bower.json';

  if (! fs.existsSync(path.join(pack, bowerFile)))
    bowerFile = '.bower.json';

  var regularJSON = JSON.parse(
    fs.readFileSync(path.join(pack, bowerFile))
  );
  var bowerJSON = json.normalize(regularJSON);
  var deps = bowerJSON.dependencies || {};
  var mains = bowerJSON.main || [];

  concatedPkgs.push(path.basename(pack));

  _.each(Object.keys(deps), function (pkg, i, l) {
    var components = pack.split(path.sep);
    var pkgpath = components.slice(0, -1).join(path.sep);

    concatPackage(path.join(pkgpath, pkg), outDir, minified);
  });

  debug('concatenating package ' + path.basename(pack) + '...');

  var files = constructFileList(pack, mains, minified);
  var concatJS = '', concatCSS = '';

  _.each(files, function (filepath, i, l) {
    var contents = fs.readFileSync(filepath) + '\n';
    var ext = filepath.split('.')[filepath.split('.').length - 1];

    if (ext === 'js' || ext === 'css')
      debug('including file ' + filepath + '...');

    if (ext === 'js')
      concatJS += contents;
    else if (ext === 'css')
      concatCSS += contents;
  });

  if (concatJS !== '' || concatCSS !== '')
    debug('writing files...');

  if (concatJS !== '')
    fs.appendFileSync(path.join(outDir, 'build.js'), concatJS);

  if (concatCSS !== '')
    fs.appendFileSync(path.join(outDir, 'build.css'), concatCSS);
}
892172
function visitPackageJSON(folderPath)
{
  let files = fs.readdirSync(folderPath);
  for (var i in files) {
    let name = files[i];
    let filePath = path.join(folderPath, files[i]);
    if(fs.statSync(filePath).isDirectory()) {
      visitPackageJSON(filePath);
    } else {
      if (name === 'package.json') {
        try {
          patchPackageJSON_preNodeGyp_modulePath(filePath);
        } catch (e) {
          console.warn(
            'Failed to patch the file : "' +
            filePath +
            '". The following error was thrown: ' +
            JSON.stringify(e)
          );
        }
      }
    }
  }
}
702620
public function loadPackages($packages)
    {
        foreach ($packages as $package => $files) {
            if (is_string($files)) {
                $this->loadPackage($files);
            } elseif (is_array($files)) {
                $this->loadPackage($package, $files);
            } elseif (is_object($files)) {
                $this->loadPackage($package, get_object_vars($files));
            }
        }
    }
1123011
function findPackage(dir, packageName) {
    let d = dir || '.';
    do {
        let f = path.join(d, 'package.json');
        if ( fs.existsSync(f) ) {
            // require(f) would look for paths relative to this module,
            // but we need it to be relative to process.cwd()
            if ( !path.isAbsolute(f) ) {
                f = fs.realpathSync(f);
            }
            const p = requireJSON(f);
            // Look for a specific project name
            if ( packageName ) {
                if ( p ) {
                    if ( p.name == packageName ) {
                        return f;
                    }
                }
            }
            // Look for any project except this one (verup)
            else {
                if ( p ) {
                    if ( (p.extra && p.extra.verup || p.verup) && p.name != 'verup' ) {
                        return f;
                    }
                }
            }
        }
        dir = d;
        d = path.join(d, '..');
    } while (d != dir && dir.slice(0,2) != '..');
    return false;
}
697396
function concatPackages (packages, outDir, minified) {
  if (! outDir) outDir = path.join('.', 'build');

  if (!fs.existsSync(outDir)) fs.mkdirSync(outDir);
  var jsFileName = path.join(outDir, 'build.js');
  if (fs.existsSync(jsFileName)){
    fs.truncateSync(jsFileName, 0);
  }
  var cssFileName = path.join(outDir, 'build.css');
  if (fs.existsSync(cssFileName)){
    fs.truncateSync(cssFileName, 0);
  }
  _.each(packages, function (pack, i, l) {
    concatPackage(pack, outDir, minified);
  });
}
393424
function processLinked(deps, processed) {
      if(_.isEmpty(deps)) {
        return;
      }
      if(!processed) {
        processed = _.clone(deps);
      }

      var newDeps = {};
      var promise = when.resolve();
      _.each(deps, function(version, link) {
        promise = promise.then(function() {
          var pkgPath = path.resolve(nodeModulesDir, link, 'package.json');
          if (!fs.existsSync(pkgPath)) { throw new Error('Invalid package at '+pkgPath); }
          var linkPackage = require(pkgPath);

          if(!_.isEmpty(linkPackage.peerDependencies)) {
            //Install OR link peer dependencies
            self.log.verbose("Installing peer dependencies " +
              JSON.stringify(_.keys(linkPackage.peerDependencies)) + " from "
              + linkPackage.name + "@" + linkPackage.version + " into " + cwd);
          }

          return self.installWorkspaceDependencies(cwd, linkPackage.peerDependencies, workspaceDescriptor, installed)
          .then(function(newResults) {
            _.extend(newDeps, newResults.linked);
          });
        });
      });

      return promise.then(function() {
        var diff = _.omit(newDeps, _.keys(processed));
        //update the global list
        var newProcessed = _.extend({}, processed, diff);
        //process only new links
        return processLinked(diff, newProcessed);
      });
    }