'use strict';

var path = require('path'),
fs = require('fs'),
Promise = require('rsvp').Promise;

var readPackageJson = function (dir) {
  return new Promise(function(resolve, reject) {
    fs.readFile(path.join(dir, 'package.json'), 'utf8', function (err, data) {
      if (err) {
        reject(err);
      } else {
        try {
          resolve(JSON.parse(data));
        } catch (err) {
          reject(err);
        }
      }
    });
  });
};

var JspmNuget = function (options, ui) {
  
};

// static configuration function
JspmNuget.configure = function(config, ui) {
  
};

// regular expression to verify package names
JspmNuget.packageFormat = /^[^\/]+\/[^\/]+/;

JspmNuget.prototype = {
  // Given a package name, return a list of versions of the looked up package name
  // return values
  // { versions: versions: {
  //     '1.2.3': { hash: 'asdf' },
  //     'branch-name': { hash: '8j3mjw8fwef7a', stable: false, meta: { custom: 'lookup data' } }
  // } }
  // OR
  // { notfound: true }
  lookup: function (packageName) {

  },
  
  // Given a package name, download version into the specified directory
  // return value: Promise containing package.json content
  download: function (packageName, version, hash, meta, dir) {
    
  }
};

module.exports = JspmNuget;

'use strict';

var JspmNuget = function (options, ui) {
  
};

// static configuration function
JspmNuget.configure = function(config, ui) {
  
};

// regular expression to verify package names
JspmNuget.packageFormat = /^[^\/]+\/[^\/]+/;

JspmNuget.prototype = {
  // Given a package name, return a list of versions of the looked up package name
  // return values
  // { versions: versions: {
  //     '1.2.3': { hash: 'asdf' },
  //     'branch-name': { hash: '8j3mjw8fwef7a', stable: false, meta: { custom: 'lookup data' } }
  // } }
  // OR
  // { notfound: true }
  lookup: function (packageName) {

  },
  
  // Given a package name, download version into the specified directory
  // return value: Promise containing package.json content
  download: function (packageName, version, hash, meta, dir) {
    
  }
};

module.exports = JspmNuget;

--- 
+++ 
@@ -1,4 +1,24 @@
 'use strict';
+
+var path = require('path'),
+fs = require('fs'),
+Promise = require('rsvp').Promise;
+
+var readPackageJson = function (dir) {
+  return new Promise(function(resolve, reject) {
+    fs.readFile(path.join(dir, 'package.json'), 'utf8', function (err, data) {
+      if (err) {
+        reject(err);
+      } else {
+        try {
+          resolve(JSON.parse(data));
+        } catch (err) {
+          reject(err);
+        }
+      }
+    });
+  });
+};
 
 var JspmNuget = function (options, ui) {
   
Add fn to read package.json
