[Pkg-javascript-commits] [node-browserify-lite] 02/03: Imported Upstream version 0.2.2

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Fri Oct 3 23:05:37 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-browserify-lite.

commit 208dd2504931d201f3379aaf889c7b2ea39c7d2b
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Fri Oct 3 23:05:24 2014 +0000

    Imported Upstream version 0.2.2
---
 index.js     | 37 +++++++++++++++++++++++--------------
 package.json |  2 +-
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/index.js b/index.js
index 211097b..6371050 100644
--- a/index.js
+++ b/index.js
@@ -250,7 +250,7 @@ function requireResolveModule(pkg, basedir, cb) {
 
   function trySearchPath() {
     var searchPath = searchPaths[index];
-    if (!searchPath) return cb(new Error("module not found"));
+    if (!searchPath) return cb(new Error("module " + pkg + " in " + basedir + " not found"));
 
     requireResolvePath(path.resolve(searchPath, pkg), function(err, resolvedFilename) {
       if (!err) return cb(null, resolvedFilename);
@@ -284,22 +284,31 @@ function resolveFile(filename, cb) {
 function resolveDirectory(dirname, cb) {
   var packageJsonPath = path.resolve(dirname, "package.json");
   fs.readFile(packageJsonPath, {encoding: 'utf8'}, function(err, packageJsonStr) {
-    var packageJson;
-    try {
-      packageJson = JSON.parse(packageJsonStr);
-    } catch (err) {
-      cb(err);
-      return;
-    }
-    var filename;
-    if (packageJson.main) {
-      filename = path.resolve(dirname, packageJson.main);
-      resolveFile(filename, tryIndex);
+    if (!err) {
+      var packageJson;
+      try {
+        packageJson = JSON.parse(packageJsonStr);
+      } catch (err) {
+        cb(new Error("Invalid package.json: " + packageJsonPath + ": "+ err.message));
+        return;
+      }
+      var filename;
+      var browserObject = packageJson.browserify || packageJson.browser;
+      if (typeof browserObject === 'string') {
+        filename = path.resolve(dirname, browserObject);
+        requireResolvePath(filename, tryIndex);
+      } else if (packageJson.main) {
+        filename = path.resolve(dirname, packageJson.main);
+        requireResolvePath(filename, tryIndex);
+      } else {
+        tryIndex(new Error("no main found in package.json"));
+      }
     } else {
-      tryIndex(new Error("no main found in package.json"));
+      tryIndex(new Error("no package.json found"));
     }
 
-    function tryIndex(err) {
+
+    function tryIndex(err, filename) {
       if (!err) return cb(null, filename);
       filename = path.resolve(dirname, "index.js");
       resolveFile(filename, function(err) {
diff --git a/package.json b/package.json
index 045ca22..10d2792 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "browserify-lite",
-  "version": "0.2.0",
+  "version": "0.2.2",
   "description": "browserify, minus some of the advanced features and heavy dependencies.",
   "main": "index.js",
   "scripts": {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-lite.git



More information about the Pkg-javascript-commits mailing list