Parses the output of `npm ll` making sure that the private sub-modules are included in the report.

@method parseNPMLL
@param {Function} cb - Callback to be invoked when the operation is complete.
164537
function parseNPMLL(cb) {
	/* read the original package.json file and parse it */
	const packagePath = path.join(process.cwd(), 'package.json')
	const packageJsonContent = fs.readFileSync(packagePath, 'utf8')
	const packageJson = JSON.parse(packageJsonContent)

	/* save a version of package.json with the privateSubmodules added to the dependencies object */
	const privateSubmodules = packageJson.privateSubmodules
	const dependencies = packageJson.dependencies
	Object.keys(privateSubmodules || {}).forEach(key => {
		if (!dependencies.hasOwnProperty(key)) {
			dependencies[key] = privateSubmodules[key]
		}
	})
	fs.writeFile(packagePath, JSON.stringify(packageJson), err => {
		if (err) throw err

		/* process the output of `npm ll` */
		let output
		try {
			output = cp.execSync('npm ll --json', { env: process.env })
		} catch (e) {
			output = e.stdout
		}

		/* restore the previous package.json */
		fs.writeFile(packagePath, packageJsonContent, err => {
			if (err) throw err

			/* parse the output and call the callback */
			let parsed
			try {
				parsed = JSON.parse(output)
			} catch (e) {
				console.warn('Cannot parse `npm ll` output:', e)
				parsed = null
			}
			cb(parsed)
		})
	})
}
683982
function (cb) {
    this.reset();
    var bundle = this.bundle;
    var self = this;
    async.waterfall([
      function (wfCb) {
        if (self.noclean) {
          wfCb();
        } else {
          // Remove the output directory if it exists
          existsCompat(self.outputTo, function (exists) {
            if (exists) {
              if (self.verbose) {
                console.log('compileAssets: removing output directory: ' + self.outputTo);
              }
              rimraf(self.outputTo, wfCb);
            } else {
              wfCb();
            }
          });
        }
      },
      function (wfCb) {
        if (self.verbose) {
          console.log('compileAssets: starting asset discovery phase.');
        }
        executePhase(self.phases.discovery, bundle, wfCb);
      },
      function (b, wfCb) {
        if (self.verbose) {
          console.log('compileAssets: starting compilation phase.');
        }
        try {
          // Get the correct order of asset dependencies
          var orderedAssets = bundle.getProcessingOrder().map(function (assetFilePath) {
            return bundle.getAsset(assetFilePath);
          });
          async.eachSeries(orderedAssets, function (asset, eachCb) {
            setImmediateCompat(function() {
              executePhase(self.phases.compilation, asset, eachCb);
            });
          }, wfCb);
        }
        catch (e) {
          wfCb(e);
        }
      }, function (wfCb) {
        if (self.verbose) {
          console.log('compileAssets: starting post-compilation phase.');
        }
        async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) {
          executePhase(self.phases.postCompilation, asset, eachCb);
        }, wfCb);
      }, function (wfCb) {
        if (self.verbose) {
          console.log('compileAssets: starting output phase.');
        }
        async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) {
          executePhase(self.phases.output, asset, eachCb);
        }, wfCb);
      }
    ], cb);
  }
1111390
function linkModules (pkg, target, cb) {
  log.silly(pkg.modules, "linkModules")
  log.verbose(target, "linkModules")
  if (target === npm.root
      && !target.match(/node_modules$/)
      && -1 === require.paths.indexOf(target)) {
    log.warn("modules installing to "+target+", outside NODE_PATH")
  }
  if (!pkg.modules) pkg.modules = {}
  var mod = pkg.modules

  // FIXME: remove in 0.3.0, and uncomment this functionality in
  // lib/utils/read-json.js
  if (pkg.main) {
    mod["index.js"] = pkg.main
    delete pkg.main
  }

  var versionDir = path.join(npm.dir, pkg.name, pkg.version)
    , pkgDir = path.join(versionDir, "package")

  asyncMap(Object.keys(mod), function (key, cb) {
    writeShim
      ( path.join(pkgDir, mod[key])
      , path.join(target, key.replace(/\.js$/, '')+".js")
      , path.join(versionDir, "node_modules")
      , cb
      )
  }, function (er) {
    if (er) return cb(er)
    mkdir(target, function (er) {
      if (er) return cb(er)
      pkg._npmConfig = npm.config.get()
      pkg._env = {}
      Object.keys(process.env).forEach(function (e) {
        if (!e.match(/^npm_/i)) return
        pkg._env[e] = process.env[e]
      })
      pkg._npmPaths = { root : npm.root
                      , dir : npm.dir
                      , cache : npm.cache
                      , tmp : npm.tmp
                      , package : pkgDir
                      , modules : target
                      , dependencies : path.join(versionDir, "node_modules")
                      }
      var pkgCode = "module.exports = "
                  + JSON.stringify(pkg, null, 2)
                  + "\n"
      delete pkg._npmConfig
      delete pkg._npmPaths
      fs.writeFile(path.join(target,"package.json.js"), pkgCode, "utf8", cb)
    })
  })
}
682886
function checkParentNodeModules(cb) {
    parentNodeModules = getParentNodeModules();

    // Check if a node_modules folder exists in any folder from the one above.
    // to top /.
    if (parentNodeModules.length) {
        let str;
        str = 'A "node_modules" folder was detected in ';
        str += parentNodeModules.length === 1 ? 'a parent directory: ' :
            'these parent directories: ';
        warn(str);
        parentNodeModules.forEach(dir => logList(dir));
        log();

        str = 'If you continue, ' + (parentNodeModules.length === 1 ?
                                     'that folder' : 'those folders');
        log(str + ' will be temporarily renamed. This');
        log('might affect only live node processes. If unsure, choose No ');
        log('and try to install nodeGame on another path.');
        log();
        if (!yes) {
            confirm('Continue? [y/n]', function(ok) {
                if (ok) {
                    log();
                    let res = renameParentNodeModules(parentNodeModules);
                    if (res !== true) {
                        err('Could not rename ' + res[0]);
                        installationFailed();
                    }
                    log();
                    doInstall();
                }
                else {
                    installationAborted(true);
                    return;
                }
            });
        }
        else {
            log('Continue? [y/n] --yes');
            log();
        }
    }
    else {
        doInstall();
    }
}
926087
function _parse(loc, type, data, callback) {
  // explicit type
  if(type && type !== 'auto') {
    return _typedParse(loc, type, data, callback);
  }
  // typed via text-like extension
  if(loc && (endsWith(loc, '.txt'))) {
    return _typedParse(loc, 'text', data, callback);
  }
  // typed via JSON-like extension
  if(loc && (endsWith(loc, '.json') ||
    endsWith(loc, '.jsonld') ||
    endsWith(loc, '.json-ld'))) {
    return _typedParse(loc, 'json', data, callback);
  }
  // typed via HTML-like extension
  if(loc && (endsWith(loc, '.xml') ||
    endsWith(loc, '.html') ||
    endsWith(loc, '.xhtml'))) {
    return _typedParse(loc, 'html', data, callback);
  }
  // try ~JSON
  _typedParse(loc, 'application/ld+json', data, function(err, data) {
    if(err) {
      // try ~HTML
      return _typedParse(loc, 'text/html', data, function(err, data) {
        if(err) {
          return callback({
            message: 'Unable to auto-detect format.',
            url: loc
          });
        }
        callback(null, data);
      });
    }
    callback(null, data);
  });
}
31463
function parsePromiseLib(pl) {

    let promise;
    if (pl instanceof PromiseAdapter) {
        promise = function (func) {
            return pl.create(func);
        };
        promise.resolve = pl.resolve;
        promise.reject = pl.reject;
        promise.all = pl.all;
        return promise;
    }
    const t = typeof pl;
    if (t === 'function' || t === 'object') {
        const Root = typeof pl.Promise === 'function' ? pl.Promise : pl;
        promise = function (func) {
            return new Root(func);
        };
        promise.resolve = Root.resolve;
        promise.reject = Root.reject;
        promise.all = Root.all;
        if (typeof promise.resolve === 'function' &&
            typeof promise.reject === 'function' &&
            typeof promise.all === 'function') {
            return promise;
        }
    }

    throw new TypeError('Invalid promise library specified.');
}
748025
function(cb) {
    async.series([
      function(next){
        if (!fs.existsSync('./src')) {
          return cb()
        }
        if (!fs.existsSync('./lib')) {
          return fs.mkdir('./lib', next)
        }
        next()
      },
      function(next) {
        exec('cp -urf ./src/* ./lib/', next)
      },
      function(next) {
        compile(function(){
          if (info.pkg.json.scripts && info.pkg.json.scripts.prepublish) {
            exec('npm run prepublish', next)
          } else {
            next()
          }
        })
      }
    ], cb)
  }
61622
function _parseProcMeminfo(cb) {
  if (cb && typeof cb === 'function') {
    return fs.readFile('/proc/meminfo', function(err, meminfo) {
      if (err) {
        return cb(err);
      }
      return cb(null, _formatParsedProcMeminfo(meminfo));
    });
  }

  var meminfo = fs.readFileSync('/proc/meminfo');
  return _formatParsedProcMeminfo(meminfo);
}
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)
}
467020
function _parseSmartColonLine(line, obj) {
        //some of the value contains colon, so this is why I don't split the string using colon.
        //Lie this:
        //    Local Time is:    Fri Jun 12 23:55:27 2015 CST
        var pos = line.indexOf(':');
        var key, val;
        if (pos < 0) {//If no colon, then put this into key 'Others'
            key = 'Others';
            val = line;
        }
        else {
            key = line.substring(0, pos);
            val = line.substring(pos + 1).trim();
        }

        //Some of identity occurs multi times
        //Example data:
        //SMART support is: Available - device has SMART capability.
        //SMART support is: Enabled
        if (obj.hasOwnProperty(key)) {
            if (_.isArray(obj[key])) {
                obj[key] = obj[key].push(val);
            }
            else {
                obj[key] = [obj[key], val];
            }
        }
        else {
            obj[key] = val;
        }
        return obj;
    }
157486
function parseChildrenProperties( root, libs, com, indent ) {
  if (!Array.isArray( root.children )) {
    root.children = [ ];
  }
  root.children.forEach( function( child ) {
    debugger;
    if ( child.type != libs.Tree.TAG ) {
      return;
    }
    libs.compileChildren( child );

    if ( typeof child.attribs === 'undefined' ) {
      child.attribs = {};
    }
    if ( child.attribs.json === null ) {
      parsePropertyJSON( child, libs, com );
    }
    else {
      // By default, this is a list.
      parsePropertyList( child, libs, com, indent + "  " );
    }
  });
}
319888
function wrap_cb(fn, P) {
  return function (params) {
    return new P(function (resolve, reject) {
      fn(params, function (err) { return !err ? resolve() : reject(err); });
    });
  };
}
756475
function parseOne(p){
	var p = path.resolve(p);
	if(root === null){
		root = p;
	}
	var firstInclude = hasIncludes(p);
	var r;
	//console.log(firstInclude);
	if(firstInclude){
		r = parseFirstIncludes(p,getContent(p));
		CTS[p] = r;
		r = parseOne(p);
	} else {
		r = getContent(p);
	}
	return r;
}
105213
function parseResponse(cb) {
  return function parse(err, response, body) {
    // TODO Handel the errors
    cb(err, JSON.parse(body))
  }
}
66581
function feed(cb) {
  return function (args) {
    function resultCb(result) {
      result.forEach(function (article) {
        console.log(article.title);
      });
    }
    function jenkinsCb(jenkins) {
      if (args.job) {
        jenkins.parseJobFeed(args.job, cli.exitCb(null, resultCb));
      } else if (args.view) {
        jenkins.parseViewFeed(args.view, cli.exitCb(null, resultCb));
      } else {
        jenkins.parseFeed(cli.exitCb(null, resultCb));
      }
    }
    cb(args, jenkinsCb);
  };
}
186017
function resolveDependencies (pkg, cb) {
  if (!pkg) return topCb(new Error(
    "Package not found to resolve dependencies"))
  // link foo-1.0.3 to ROOT/.npm/{pkg}/{version}/node_modules/foo

  // see if it's bundled already
  var bundleDir = path.join( npm.dir, pkg.name, pkg.version
                           , "package", "node_modules" )
   , deps = pkg.dependencies && Object.keys(pkg.dependencies) || []
  log.verbose([pkg, deps], "deps being resolved")
  fs.readdir(bundleDir, function (er, bundledDeps) {
    if (er) bundledDeps = []
    bundledDeps.forEach(function (bd) {
      var i = deps.indexOf(bd)
      if (i !== -1) deps.splice(i, 1)
    })

    asyncMap(deps, function (i, cb) {
      var req = { name:i, version:pkg.dependencies[i] }
      log.verbose(req.name+"@"+req.version, "required")

      // see if we have this thing installed.
      fs.readdir(path.join(npm.dir, req.name), function (er, versions) {
        if (er) return cb(new Error(
          "Required package: "+req.name+"("+req.version+") not found."+
          "\n(required by: "+pkg._id+")"))
        // TODO: Get the "stable" version if there is one.
        // Look that up from the registry.
        var satis = semver.maxSatisfying(versions, req.version)
        if (satis) return cb(null, {name:req.name, version:satis})
        return cb(new Error(
          "Required package: "+req.name+"("+req.version+") not found. "+
          "(Found: "+JSON.stringify(versions)+")"+
          "\n(required by: "+pkg._id+")"))
      })
    }, function (er, found) {
      // save the resolved dependencies on the pkg data for later
      pkg._resolvedDeps = found
      cb(er, found)
    })
  })
}
171602
function(moduleName, deps, callback) {
  //if (moduleName === "jquery/selector") { debugger; }
  if (!deps && !callback) {
    return;
  }

  // Allow deps to be optional.
  if (!callback && typeof deps === "function") {
    callback = deps;
    deps = undefined;
  }

  // Ensure dependencies is never falsey.
  deps = deps || [];

  // Normalize the dependencies.
  deps = deps.map(function(dep) {
    if (dep.indexOf("./") === -1) {
      return dep;
    }

    // Take off the last path.
    var normalize = moduleName.split("/").slice(0, -1).join("/");

    //console.log(normalize, dep, define.join(normalize, dep));
    return define.join(normalize, dep);
  });

  // Attach to the module map.
  define.map[moduleName] = {
    moduleName: moduleName,
    deps: deps,
    callback: callback
  };
}