question: public Pair < IStatus , Collection < File > > adaptPackages ( Iterable < String > namesOfPackagesToAdapt ) { final File nodeModulesFolder = new File ( installLocationProvider . getTargetPlatformNodeModulesLocation ( ) ) ; final Collection < String > names = newHashSet ( namesOfPackagesToAdapt ) ; final Collection < File > adaptedProjects = newHashSet ( ) ; final File [ ] packageRoots = nodeModulesFolder . listFiles ( null ) ; final MultiStatus status = statusHelper . createMultiError ( "Error while adapting npm packages to N4JS format." ) ; final File n4jsdsFolder = getNpmsTypeDefinitionsFolder ( ) ; for ( File packageRoot : packageRoots ) { try { PackageJson packageJson = getPackageJson ( packageRoot ) ; final File manifest = new File ( packageRoot , N4MF_MANIFEST ) ; if ( manifest . exists ( ) && manifest . isFile ( ) ) { adaptedProjects . add ( packageRoot ) ; if ( ! names . remove ( packageRoot . getName ( ) ) ) { throw new IOException ( "Unexpected error occurred while adapting '" + packageRoot . getName ( ) + "' npm package into N4JS format." ) ; } } else { if ( manifest . isDirectory ( ) ) { throw new IOException ( "The manifest location is occupied by the folder '" + manifest + "'." ) ; } manifest . createNewFile ( ) ; try { generateManifestContent ( packageRoot , packageJson , manifest ) ; adaptedProjects . add ( packageRoot ) ; if ( ! names . remove ( packageRoot . getName ( ) ) ) { throw new IOException ( "Unexpected error occurred while adapting '" + packageRoot . getName ( ) + "' npm package into N4JS format." ) ; } } catch ( final Exception e ) { try { FileDeleter . delete ( manifest ) ; } catch ( IOException ioe ) { LOGGER . error ( "Error while trying to clean up corrupted " + manifest + " file." , e ) ; } throw e ; } } if ( n4jsdsFolder != null ) { addTypeDefinitions ( packageRoot , packageJson , manifest , n4jsdsFolder ) ; } } catch ( final Exception e ) { status . add ( statusHelper . createError ( "Unexpected error occurred while adapting '" + packageRoot . getName ( ) + "' npm package into N4JS format." , e ) ) ; } } if ( Arrays2 . isEmpty ( status . getChildren ( ) ) ) { return pair ( OK_STATUS , adaptedProjects ) ; } else { return pair ( status , emptyList ( ) ) ; } }
target:  Adapts npm packages in provided folder to the N4JS project structure. Only package folders which match requested packages are adapted. It is expected that npm flattens packages structures, therefore it is assumed that other folders are dependencies (also transitive) of the requested packages. Requested npm packages already look like N4JS projects (i.e. have N4MF manifest file), those packages are not adapted (proper structure is assumed), but they will be returned in to the caller to allow further processing (i.e. passing them to the builder). Returned set of N4JS project folders will not include those installed by the npm but without matching names in provided set of expected packages. Those packages are treated as transitive dependencies and are not return to the caller.