Skip to content

Commit

Permalink
add directory check for node_modules scan
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanjudis committed Nov 21, 2015
1 parent a9f0ce0 commit c6c8d2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ function readDirectory( projectPath, credits, seen ) {
}

deps.forEach( function( name ) {
if ( name !== '.bin' ) {
var packageJson = require( path.join( depPath, name, 'package.json' ) );
var directoryPath = path.join( depPath, name );

if (
name !== '.bin' &&
(
fs.lstatSync( directoryPath ).isDirectory() ||
fs.lstatSync( directoryPath ).isSymbolicLink()
)
) {
var packageJson = require( path.join( directoryPath, 'package.json' ) );
var author = packageUtil.getAuthor( packageJson );
var maintainers = packageUtil.getMaintainers( packageJson );

Expand All @@ -54,7 +62,7 @@ function readDirectory( projectPath, credits, seen ) {
} );
}

readDirectory( fs.realpathSync( path.join( depPath, name ) ), credits, seen );
readDirectory( fs.realpathSync( directoryPath ), credits, seen );
}
} );

Expand Down
4 changes: 0 additions & 4 deletions index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ test( 'credits - folder exists', t => {
'utf8'
);


fs.mkdirSync( `${path}/node_modules/bar` );
fs.writeFileSync(
`${path}/node_modules/bar/package.json`,
JSON.stringify( { author : 'Alice Bobson' } ),
'utf8'
);


fs.mkdirSync( `${path}/node_modules/bar/node_modules` );
fs.mkdirSync( `${path}/node_modules/bar/node_modules/boom` );

fs.writeFileSync(
`${path}/node_modules/bar/node_modules/boom/package.json`,
JSON.stringify( { author : { name : 'Alice Bobson' } } ),
Expand All @@ -50,7 +47,6 @@ test( 'credits - folder exists', t => {

fs.mkdirSync( `${path}/node_modules/baz/node_modules` );
fs.mkdirSync( `${path}/node_modules/baz/node_modules/boing` );

fs.writeFileSync(
`${path}/node_modules/baz/node_modules/boing/package.json`,
JSON.stringify( { author : 'Bob Calsow <bob@calsow.io>' } ),
Expand Down

0 comments on commit c6c8d2d

Please sign in to comment.