packages/oss-report-builder/index.js
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)
		})
	})
}
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)
		})
	})
}
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 ) } ) } ) }
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.
Parses the output of npm ll making sure that the private sub - modules are included in the report .