Permalink
Browse files

publishConfig support

  • Loading branch information...
1 parent b9b86e9 commit c4329f87b8369ce2569cdc1ba114fc8343a2630a @vladtsf committed Jan 24, 2013
View
@@ -77,7 +77,7 @@ class Package
#
getPackageURL: ( packageName, version = "latest" ) ->
# lookup registry url
- registry = @registry ? @rc.registry
+ registry = @registry ? @pkg.publishConfig?.registry ? @rc.registry
# parse base registry url
urlObj = url.parse registry
@@ -0,0 +1,17 @@
+{
+ "name": "dummy-package-name",
+ "version": "0.0.0",
+ "publishConfig": {
+ "registry":"http://my-internal-registry.local"
+ },
+ "dependencies": {
+ "coffee-script": "*",
+ "commander": "*",
+ "async": "*",
+ "foo": "*"
+ },
+ "devDependencies": {
+ "mocha": "1.8.0",
+ "sinon": "*"
+ }
+}
View
@@ -16,6 +16,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" ),
+ publishConfig: path.join( __testsRootDir, "fixtures", "packages", "publishConfig.json" ),
broken: path.join( __testsRootDir, "fixtures", "packages", "broken.json" ),
nodeModules: path.join( __testsRootDir, "fixtures", "packages", "node_modules" )
}
@@ -5,17 +5,20 @@ module.exports = class Packages
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, "publish-config"
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, "publish-config", "package.json" ), fs.readFileSync( __fixturesPaths.publishConfig )
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 @publishConfig = pkgtool path.join __tmpDir, "publish-config"
try @broken = pkgtool path.join __tmpDir, "broken"
try @empty = pkgtool path.join __tmpDir, "empty"
try @nonexistent = pkgtool path.join __tmpDir, "nonexistent"
@@ -25,4 +28,5 @@ module.exports = class Packages
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, "publish-config"
try wrench.rmdirSyncRecursive path.join __tmpDir, "broken"
@@ -23,6 +23,11 @@ describe "Package", ->
@successful.getPackageURL( "mocha", "1.0.0" ).should.equal "#{ @npmrc.registry }mocha/1.0.0"
done()
+ it "should get version from publishConfig section of package.json", ( done ) ->
+ @publishConfig.load ( err ) ->
+ @getPackageURL( "mocha", "1.0.0" ).should.equal "http://my-internal-registry.local/mocha/1.0.0"
+ done()
+
describe "@load()", ->
it "should define registry, which specified in .npmrc", ( done ) ->

0 comments on commit c4329f8

Please sign in to comment.