NPM 3 compatibility fix
196685
function() {
    var packageName;
    var parentFolderName = path.basename(path.resolve('..'));
    var isSubPackage = parentFolderName === 'node_modules';
    var isLocalDepsAvailable = fs.existsSync('node_modules/grunt-autoprefixer') && fs.existsSync('node_modules/grunt-contrib-cssmin');

    if (isSubPackage && !isLocalDepsAvailable) {
        packageName = 'load-grunt-parent-tasks';
    } else {
        packageName = 'load-grunt-tasks';
    }

    return packageName;
}
1170676
function checkNpm () {
  /**
   * CI 环境下不执行，不然单元测试会报错，系统测试前会单独检测并升级 npm
   */
  if (process.env.CI) {
    return
  }

  const { npmVersion, npmLifecycleVersion, pass } = npmVersions

  info(
    `npm version: ${npmVersion}`,
    `npm-lifecycle version: ${npmLifecycleVersion || '-'}`
  )

  if (!pass) {
    error(
      'elint 在当前的 npm 版本下无法正常运行，请升级 npm 后再安装',
      '更多信息请访问：http://t.cn/Rg7xvP0'
    )

    process.exit(1)
  }
}
1314841
function publishNpm(pck) {
	var pkg = null, auth = [], npm = null;
	if (pck.commit.hasNpmToken && pck.commit.pkgPath) {
		try {
			npm = require('npm');
		} catch (e) {
			pck.rollCall.error('npm publish failed because npm module is not found (use "npm link npm")', e).resume();
			return;
		}
		rbot.log.info('Publishing to npm');
		go();
	} else {
		rbot.log.verbose('Skipping npm publish for ' + pck.commit.pkgPath + ' version ' + pck.commit.version);
	}
	function go() {
		var pd = pck.commit.versionPkg({
			replacer : pck.options.pkgJsonReplacer,
			space : pck.options.pkgJsonSpace,
			readOnly : true
		});
		pkg = pd.pkg;
		if (!pkg || !pkg.author || !pkg.author.email) {
			pck.rollCall.error('npm publish failed due to missing author.email in ' + pck.commit.pkgPath);
		} else {
			auth = (typeof pck.commit.npmToken === 'function' ? pck.commit.npmToken() : pck.commit.npmToken);
			auth = typeof auth === 'string' && (auth = new Buffer(auth, 'base64').toString()) ? auth.split(':') : [];
			if (auth.length !== 2) {
				pck.rollCall.error('npm NPM_TOKEN is missing or invalid');
			} else {
				pck.rollCall.pause(function() {
					npm.load({}, function(e) {
						if (e) {
							pck.rollCall.error('npm load failed', e).resume();
						} else {
							pck.rollCall.pause(adduser);
						}
					});
				});
			}
		}
	}
	function adduser() {
		npm.config.set('email', pkg.author.email, 'user');
		npm.registry.adduser(pck.options.npmRegistryURL, auth[0], auth[1], pkg.author.email, aucb);
		function aucb(e) {
			if (e) {
				pck.rollCall.error('npm publish failed to be authenticated', e).resume();
			} else {
				pck.rollCall.pause(pub);
			}
		}
	}
	function pub() {
		var pargs = [];
		if (pck.options.npmTag) {
			pargs.push('--tag ' + pck.options.npmTag);
		}
		rbot.log.info('npm publish ' + pargs.join(' '));
		// switch to the master branch so publish will pickup the right version
		pck.command.chkoutCmd(pck.commit.branch);
		npm.commands.publish(pargs, function(e) {
			if (e) {
				pck.rollCall.error('npm publish failed', e).resume();
			} else {
				pck.rollCall.pause(postPub);
			}
		});
		function postPub() {
			pck.command.chkoutRun(null, function() {
				rbot.log.verbose('npm publish complete');
				pck.rollCall.resume();
			});
		}
	}
}
274829
function install(args, cb) {
  args = ['install', '--save-dev'].concat(args);
  utils.spawn('npm', args, {stdio: 'inherit'})
    .on('error', cb)
    .on('close', function(code, err) {
      cb(err, code);
    });
}
831859
function dependencyLink (pkg, cb) {
  var dependencies = path.join(npm.dir, pkg.name, pkg.version, "node_modules")
    , depBin = path.join(npm.dir, pkg.name, pkg.version, "dep-bin")
  asyncMap(pkg._resolvedDeps, function (dep, cb) {
    log.silly(dep, "dependency")
    var fromRoot = path.join(npm.dir, dep.name, dep.version)
      , dependsOn = path.join( npm.dir, pkg.name, pkg.version
                             , "dependson", dep.name + "@" + dep.version
                             )
    link(fromRoot, dependsOn, cb)
  }, function (dep, cb) {
    var depDir = path.join(npm.dir, dep.name, dep.version, "package")
    readJson(path.join(depDir, "package.json"), function (er, dep) {
      if (er) return cb(er)
      loadPackageDefaults(dep, function (er, dep) {
        if (er) return cb(er)
        asyncMap([dep], function (dep) {
          var toLib = path.join(dependencies, dep.name)
          linkModules(dep, toLib, cb)
        }, function (dep, cb) {
          // link the bins to this pkg's "dep-bin" folder.
          linkBins(dep, depBin, false, cb)
        }, cb)
      })
    })
  }, cb)
}
1127680
async function updatePackageJSON (version) {
  ['package.json'].forEach(async fileName => {
    const filePath = path.resolve(__dirname, '..', fileName)
    const file = require(filePath)
    file.version = version
    await writeFile(filePath, JSON.stringify(file, null, 2))
  })
}
193125
function handleMismatch(results, config) {
  if (results.length) {
    var message = 'Out of date packages: \n' + results.map(function (p) {
      return moduleInfo(p);
    }).join('\n');
    if (config.throw === undefined || config.throw !== undefined && config.throw) {
      throw new _gulpUtil.PluginError('gulp-npm-check', {
        name: 'NpmCheckError',
        message: message
      });
    } else {
      (0, _gulpUtil.log)(_gulpUtil.colors.yellow('gulp-npm-check\n', message));
    }
  } else {
    (0, _gulpUtil.log)('All packages are up to date :)');
  }
}
187785
public function update_8009003() {
    $composer_json = $this->updater->getComposerJson();

    $composer_json['extra']['installer-types'][] = 'bower-asset';
    $composer_json['extra']['installer-types'][] = 'npm-asset';
    $composer_json['extra']['installer-paths']['docroot/libraries/{$name}'][] = 'type:bower-asset';
    $composer_json['extra']['installer-paths']['docroot/libraries/{$name}'][] = 'type:npm-asset';

    // Add the Asset Packagist repository if it does not already exist.
    if (isset($composer_json['repositories'])) {
      $repository_key = NULL;
      foreach ($composer_json['repositories'] as $key => $repository) {
        if ($repository['type'] == 'composer' && strpos($repository['url'], 'https://asset-packagist.org') === 0) {
          $repository_key = $key;
          break;
        }
      }
      if (is_null($repository_key)) {
        $composer_json['repositories']['asset-packagist'] = [
          'type' => 'composer',
          'url' => 'https://asset-packagist.org',
        ];
      }
    }

    $projectAcsfHooks = $this->updater->getRepoRoot() . '/factory-hooks';
    $acsf_inited = file_exists($projectAcsfHooks);
    if ($acsf_inited) {
      $composer_json['config']['platform']['php'] = '5.6';
    }

    $this->updater->writeComposerJson($composer_json);

    $messages = [
      "Your composer.json file has been modified to be compatible with Lightning 2.1.8+.",
      "You must execute `composer update` to update your lock file.",
    ];
    $formattedBlock = $this->updater->getFormatter()->formatBlock($messages, 'ice');
    $this->updater->getOutput()->writeln("");
    $this->updater->getOutput()->writeln($formattedBlock);
    $this->updater->getOutput()->writeln("");
  }
216167
function resolveVersion(plugin) {
    var npmId = Plugin.nameToNpmID(plugin.getName());
    var requiredVersion = plugin.getVersion();

    if (plugin.isGitDependency()) {
        return Promise.resolve(requiredVersion);
    }

    return initNPM()
    .then(function() {
        return Promise.nfcall(npm.commands.view, [npmId + '@' + requiredVersion, 'engines'], true);
    })
    .then(function(versions) {
        versions = Immutable.Map(versions).entrySeq();

        var result = versions
            .map(function(entry) {
                return {
                    version: entry[0],
                    gitbook: (entry[1].engines || {}).gitbook
                };
            })
            .filter(function(v) {
                return v.gitbook && gitbook.satisfies(v.gitbook);
            })
            .sort(function(v1, v2) {
                return semver.lt(v1.version, v2.version)? 1 : -1;
            })
            .get(0);

        if (!result) {
            return undefined;
        } else {
            return result.version;
        }
    });
}
621238
function linkPackages(pathToPkgs) {
  const pkgs = pathToPkgs.join(' ');
  return execa
    .shell(`npm link ${pkgs}`)
    .then(() => log('Succesfully linked'));
}
1101124
function updateManifests() {
      function updateVersion( name ) {
        var _ = grunt.util._;
        var manifest = grunt.file.readJSON(name);

        manifest = JSON.stringify(_.extend(manifest, {version: grunt.option('version')}), null, 2);
        grunt.file.write(name, manifest);
      }
      return Q.fcall(function() {
        var files = [
          path.join('./', 'package.json'),
          path.join('./', 'bower.json')
        ];
        files.forEach(function(item){
          //grunt.log.ok(item);
          if ( existsFilePath(item) ) {
            updateVersion(item);
          }
        });
      });
    }
1194410
function ensureGagarinVersionsMatch(pathToApp, verbose) {

  var pathToMeteorPackages = path.join(pathToApp, '.meteor', 'packages');
  var nodeModuleVersion    = require('../../package.json').version;

  return new Promise(function (resolve, reject) {

    utils.getGagarinPackageVersion(pathToApp).then(function (packageVersion) {

      if (packageVersion === nodeModuleVersion) {
        logs.system("node module and smart package versions match, " + packageVersion);
        return resolve();
      }

      tools.getReleaseVersion(pathToApp).then(function (meteorReleaseVersion) {

        if (meteorReleaseVersion < "0.9.0") {
          // really, we can do nothing about package version
          // without a decent package management system
          logs.system("meteor version is too old to automatically fix package version");
          return resolve();
        }

        logs.system("meteor add anti:gagarin@=" + nodeModuleVersion);

        var meteor = spawn('meteor', [ 'add', 'anti:gagarin@=' + nodeModuleVersion ], {

          stdio: verbose ? 'inherit' : 'ignore', cwd: pathToApp
        });

        /*
        meteor.stdout.on('data', function (data) {
          if (!verbose) {
            return;
          }
          process.stdout.write(chalk.gray(stripAnsi(data)));
        });
        */

        meteor.on('error', reject);

        meteor.on('exit', function (code) {
          if (code > 0) {
            return reject(new Error('meteor exited with code ' + code));
          }
          logs.system("anti:gagarin is now in version " + nodeModuleVersion);
          resolve();
        });

      }).catch(reject);

    }).catch(reject);

  }); // Promise
}
59139
function getInstalledNPMVersion () {
  return new Promise((resolve, reject) => {
    let nodeVersion

    exec('npm -v', (err, stdout) => {
      if (err) {
        reject(new Error('Could not determine npm version.'))
      } else {
        nodeVersion = stdout.replace(/\n/, '')
        resolve(nodeVersion)
      }
    })
  })
}
196437
def fix_2to3(source,
             aggressive=True, select=None, ignore=None, filename=''):
    """"""
    if not aggressive:
        return source

    select = select or []
    ignore = ignore or []

    return refactor(source,
                    code_to_2to3(select=select,
                                 ignore=ignore),
                    filename=filename)
22777
function bumpTask(complete) {
  util.log('Current version:', util.colors.cyan(pkg.version));
  var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType) {
    return versionType + ' (v' + semver.inc(pkg.version, versionType) + ')';
  });
  inquirer.prompt({
    type: 'list',
    name: 'version',
    message: 'What version update would you like?',
    choices: choices
  }).then(function(res) {
    var increment = res.version.split(' ')[0],
      newVersion = semver.inc(pkg.version, increment);

    // Set the new versions into the package object
    pkg.version = newVersion;

    // Write these to their own files, then build the output
    fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));

    complete();
  });
}
1150473
function(loader, packageJSON, isRoot){
		var config = utils.pkg.config(packageJSON);
		var hasConfig = !!config;

		// convert npmIgnore
		var npmIgnore = hasConfig && config.npmIgnore;
		function convertToMap(arr) {
			var npmMap = {};
			for(var i = 0; i < arr.length; i++) {
				npmMap[arr[i]] = true;
			}
			return npmMap;
		}
		if(npmIgnore && typeof npmIgnore.length === 'number') {
			npmIgnore = config.npmIgnore = convertToMap(npmIgnore);
		}
		// convert npmDependencies
		var npmDependencies = hasConfig && config.npmDependencies;
		if(npmDependencies && typeof npmDependencies.length === "number") {
			config.npmDependencies = convertToMap(npmDependencies);
		}
		npmIgnore = npmIgnore || {};

		var deps = {};

		addDeps(packageJSON, packageJSON.peerDependencies || {}, deps,
				"peerDependencies", {_isPeerDependency: true});

		addDeps(packageJSON, packageJSON.dependencies || {}, deps, "dependencies");

		if(isRoot) {
			addDeps(packageJSON, packageJSON.devDependencies || {}, deps,
				   "devDependencies");
		}

		return deps;
	}
1069191
function updateDepsTo (arg, cb) {
  asyncMap(arg._others, function (o, cb) {
    updateOtherVersionDeps(o, arg, cb)
  }, cb)
}