forked from coolaj86/node-pakmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhas-browser.js
45 lines (39 loc) · 1.09 KB
/
has-browser.js
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
/*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.findBrowser = function (cb, fullpath) {
var emitter = rwalk(fullpath)
;
emitter.on('nodes', function (next, err, dir, stats) {
var hasBrowser
;
if (err) {
//console.error(err);
//console.error('couldn\'t find ' + process.argv[2]);
next();
return;
}
hasBrowser = stats.some(function (stat) {
return 'browser' === stat.name;
});
dir = path.normalize(dir);
if (hasBrowser) {
if (path.normalize(dir) === path.normalize(fullpath)) {
//console.log('this is probably a server app');
cb('node');
} else {
//console.log('this is probably a browser app (below the browser folder)');
cb('browser');
}
return;
}
next();
});
emitter.on('end', function () {
cb('guess');
});
};
}());