Permalink
Browse files

Fixed issue with empty devDependencies

  • Loading branch information...
1 parent 399c16a commit 21e37b243a21dfdf0231217834d753e349e18205 @vladtsf committed Jan 23, 2013
Showing with 11 additions and 5 deletions.
  1. +2 −2 lib/package.coffee
  2. +1 −0 test/helpers.js
  3. +5 −0 test/helpers/packages.coffee
  4. +3 −3 test/specs/programmatic/package.coffee
View
@@ -268,15 +268,15 @@ class Package
return callback.call( @, err ) if err
# find packages in node_modules
- glob ( path.join ( path.dirname @path ), "**", "package.json" ), ( err, files ) =>
+ glob ( path.join ( path.dirname @path ), "node_modules", "*", "package.json" ), ( err, files ) =>
return callback.call( @, err ) if err
for own file in files
try
{ name, version } = require file
# if this package not listed in dependencies, add it
- unless ( name in Object.keys @dependencies ) or ( name in Object.keys @devDependencies )
+ unless ( name in Object.keys ( @dependencies ? {} ) ) or ( name in Object.keys ( @devDependencies ? {} ) )
@dependencies[ name ] = version
callback.call @
View
@@ -14,6 +14,7 @@ global.__binaryPath = path.join( __dirname, "bin", "pkgtool" )
global.__fixturesPaths = {
successful: path.join( __testsRootDir, "fixtures", "packages", "successful.json" ),
+ foo: path.join( __testsRootDir, "fixtures", "packages", "node_modules", "foo", "package.json" ),
broken: path.join( __testsRootDir, "fixtures", "packages", "broken.json" ),
nodeModules: path.join( __testsRootDir, "fixtures", "packages", "node_modules" )
}
@@ -4,14 +4,18 @@ module.exports = class Packages
try fs.mkdirSync path.join __tmpDir, "empty"
try fs.mkdirSync path.join __tmpDir, "successful"
try fs.mkdirSync path.join __tmpDir, "successful2"
+ try fs.mkdirSync path.join __tmpDir, "successful3"
try fs.mkdirSync path.join __tmpDir, "broken"
try fs.writeFileSync path.join( __tmpDir, "successful", "package.json" ), fs.readFileSync( __fixturesPaths.successful )
try fs.writeFileSync path.join( __tmpDir, "successful2", "package.json" ), fs.readFileSync( __fixturesPaths.successful )
+ try fs.writeFileSync path.join( __tmpDir, "successful3", "package.json" ), fs.readFileSync( __fixturesPaths.foo )
try fs.writeFileSync path.join( __tmpDir, "broken", "package.json" ), fs.readFileSync( __fixturesPaths.broken )
try wrench.copyDirSyncRecursive __fixturesPaths.nodeModules, path.join( __tmpDir, "successful2", "node_modules" )
+ try wrench.copyDirSyncRecursive __fixturesPaths.nodeModules, path.join( __tmpDir, "successful3", "node_modules" )
try @successful = pkgtool path.join __tmpDir, "successful"
try @successful2 = pkgtool path.join __tmpDir, "successful2"
+ try @successful3 = pkgtool path.join __tmpDir, "successful3"
try @broken = pkgtool path.join __tmpDir, "broken"
try @empty = pkgtool path.join __tmpDir, "empty"
try @nonexistent = pkgtool path.join __tmpDir, "nonexistent"
@@ -20,4 +24,5 @@ module.exports = class Packages
try wrench.rmdirSyncRecursive path.join __tmpDir, "empty"
try wrench.rmdirSyncRecursive path.join __tmpDir, "successful"
try wrench.rmdirSyncRecursive path.join __tmpDir, "successful2"
+ try wrench.rmdirSyncRecursive path.join __tmpDir, "successful3"
try wrench.rmdirSyncRecursive path.join __tmpDir, "broken"
@@ -112,13 +112,13 @@ describe "Package", ->
describe "@expand()", ->
it "should lookup dependencies which not specified in package.json in node_modules directory", ( done ) ->
- @successful.load ( err ) ->
+ @successful3.load ( err ) ->
@expand ( err ) ->
- @dependencies.should.have.property "dummy-package-name", "0.0.0"
+ @dependencies.should.have.property "foo", "0.0.1"
done()
it "should invoke callback", ( done ) ->
- @successful.load ( err ) ->
+ @successful3.load ( err ) ->
@expand done
describe "@hold()", ->

0 comments on commit 21e37b2

Please sign in to comment.