-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhas-package.js
More file actions
46 lines (38 loc) · 1004 Bytes
/
has-package.js
File metadata and controls
46 lines (38 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/
(function () {
"use strict";
var rwalk = require('./rwalk').rwalk
, path = require('path')
;
exports.findPackage = function (cb, fullpath) {
var emitter = rwalk(fullpath)
;
emitter.on('nodes', function (next, err, dir, stats) {
var hasPackage
;
if (err) {
//console.error(err);
//console.error('couldn\'t find ' + process.argv[2]);
next();
return;
}
hasPackage = stats.some(function (stat) {
if ('package.json' === stat.name) {
return true;
}
});
if (!hasPackage) {
next();
return;
}
//try {
cb(require(path.join(dir, 'package.json')).browserDependencies ? 'browser' : 'guess');
//} catch(e) {
// next();
//}
});
emitter.on('end', function () {
cb('guess');
});
};
}());