Permalink
Browse files

Asynchronous rc library

  • Loading branch information...
1 parent 00bc0d4 commit 438c6fac356218b097980d849b8331f5f6b0df51 @vladtsf committed Feb 4, 2013
Showing with 23 additions and 21 deletions.
  1. +17 −16 lib/package.coffee
  2. +1 −1 package.json
  3. +1 −1 test/helpers.js
  4. +4 −3 test/specs/programmatic/package.coffee
View
@@ -3,7 +3,7 @@
class Package
fs = require "fs"
- rc = require "rc"
+ rc = require "runtime-configuration"
url = require "url"
util = require "util"
glob = require "glob"
@@ -154,24 +154,25 @@ class Package
return callback.call( @, err ) if err
# load npmrc configuration
- @rc = rc "npm", registry: "https://registry.npmjs.org/"
+ rc "npm", registry: "https://registry.npmjs.org/", ( err, config ) =>
+ @rc = config
- try
- # try to load info from package.json
- @pkg = @require @path
+ try
+ # try to load info from package.json
+ @pkg = @require @path
- # fill dependencies
- @dependencies = @pkg.dependencies
- @devDependencies = @pkg.devDependencies
+ # fill dependencies
+ @dependencies = @pkg.dependencies
+ @devDependencies = @pkg.devDependencies
- callback.call @
- catch e
- if e.code is "ENOENT"
- # if package.json not exists, should initialize dependencies
- @create callback
- else
- # if package.json is broken
- callback.call @, e
+ callback.call @
+ catch e
+ if e.code is "ENOENT"
+ # if package.json not exists, should initialize dependencies
+ @create callback
+ else
+ # if package.json is broken
+ callback.call @, e
@
View
@@ -11,7 +11,7 @@
"request": "2.12.0",
"wrench": "1.4.4",
"colors": "0.6.0-1",
- "rc": "0.0.6"
+ "runtime-configuration": "0.1.1"
},
"devDependencies": {
"mocha": "1.8.1",
View
@@ -1,7 +1,7 @@
global.fs = require( "fs" )
global.path = require( "path" )
global.wrench = require( "wrench" )
-global.rc = require( "rc" )
+global.rc = require( "runtime-configuration" )
global.sinon = require( "sinon" )
global.request = require( "request" )
global.exec = require('child_process').exec
@@ -1,8 +1,9 @@
describe "Package", ->
- before ->
- @npmrc = rc "npm", registry: "https://registry.npmjs.org/"
-
+ before ( done ) ->
+ rc "npm", registry: "https://registry.npmjs.org/", ( err, @npmrc ) =>
+ done()
+
describe "@lookup()", ->
it "should lookup package.json in specified directory", ( done ) ->

0 comments on commit 438c6fa

Please sign in to comment.