-
Notifications
You must be signed in to change notification settings - Fork 0
/
be-goods.es5.js
161 lines (125 loc) · 14.6 KB
/
be-goods.es5.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
'use strict';
exports.__esModule = true;
exports.logger = exports.pkg = undefined;
exports.isLocal = isLocal;
exports.prefquire = prefquire;
exports.myRequire = myRequire;
exports.isSmth = isSmth;
exports.isGulp = isGulp;
exports.gulpIsHelpful = gulpIsHelpful;
exports.gulpHelpify = gulpHelpify;
exports.gulpTask = gulpTask;
require('source-map-support/register');
var _ramda = require('ramda');
var _ramda2 = _interopRequireDefault(_ramda);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _gulpHelp = require('gulp-help');
var _gulpHelp2 = _interopRequireDefault(_gulpHelp);
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _tracer = require('tracer');
var _tracer2 = _interopRequireDefault(_tracer);
var _isThere = require('is-there');
var _isThere2 = _interopRequireDefault(_isThere);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var pkg = exports.pkg = require(_path2.default.join(process.cwd(), 'package.json'));
var logger = exports.logger = _tracer2.default.console({
'filters': { 'log': _chalk2.default.green, 'warn': _chalk2.default.yellow, 'error': _chalk2.default.red },
'format': '<' + pkg.name + ' using {{path}}:{{line}}>\n{{message}}\n'
});
function myRequirePath(name) {
var home = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var place = _path2.default.join(home, 'node_modules/' + name);
var where = _path2.default.normalize(process.cwd() + '/' + place);
try {
var main = require(_path2.default.join(where, 'package.json')).main || 'index.js';
return _path2.default.join(where, main);
} catch (e) {
return undefined;
}
}
function isLocal(name) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var o = {};
o.strict = opts === true || opts.strict || false; // opts === true is strict
var dep = _ramda2.default.has(name);
var isDependency = dep(pkg.dependencies || {}) || dep(pkg.devDependencies || {});
var exists = o.strict ? (0, _isThere2.default)(myRequirePath('gulp')) : true;
return isDependency && exists;
}
function prefquireHow(o) {
o.module = o.module || 'beverage';
o.locate = o.locate || 'node_modules/' + o.module;
o.dev = o.dev || false; // is it devDependencies that are expected?
o.logPath = o.logPath || false; // log each path before trying to require it
o.throwOnError = o.throwOnError || true;
o.exitOnError = o.exitOnError || false; // uncaught throw will cause exit anyway
return o;
}
function prefquire() {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var def = prefquireHow(opts);
return function (name) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var o = prefquireHow(_ramda2.default.merge(def, opts)); // override-able defaults
var elsewhere = o.forceLocal || isLocal(name) ? undefined : o.locate;
try {
// undefined = local means relative to `process.cwd()` it's expected to be
// elsewhere is to `locate` it in a default `module`'s dependencies`
var reqPath = myRequirePath(name, elsewhere);
if (o.logPath) {
console.log('Requiring: ' + reqPath);
}
return require(reqPath);
} catch (e) {
var dependency = o.dev ? 'devDependency' : 'dependency';
var wordLocal = o.forceLocal ? 'local ' : '';
console.error(_chalk2.default.red('Could not find or require module ' + name + '!'));
console.error('Please install ' + name + ' as a ' + wordLocal + dependency + '.');
if (o.throwOnError) {
throw new Error(e);
}
if (o.exitOnError) {
process.exit(1);
}
}
};
}
// TODO: deprecate / refactor?
// Its only value is perhaps:
// 1. being more concise than prefquire setup (just one call, minimum args)
// 2. able to require a module from somewhere without trying locally first
// if kept, refactor it to use prefquire...
function myRequire(name) {
var home = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
console.warn(_chalk2.default.red('Please look at the prefquire function instead.'));
console.warn('Not sure what the future of myRequire will hold...');
return require(myRequirePath(name, home));
}
function isSmth(o, what) {
if (((o || {}).constructor || {}).name === what) {
return true;
} else {
return false;
}
}
function isGulp(o) {
return isSmth(o, 'Gulp');
}
function gulpIsHelpful(gulp) {
return _ramda2.default.is(Object, _ramda2.default.path(['help', 'help'], gulp.tasks));
}
function gulpHelpify(gulp, opts) {
return gulpIsHelpful(gulp) ? gulp : (0, _gulpHelp2.default)(gulp, opts);
}
// Helpful task creation. The given desc is discarded if gulp isn't gulp-help "helpful".
function gulpTask(gulp, name, desc) {
for (var _len = arguments.length, rest = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
rest[_key - 3] = arguments[_key];
}
var args = gulpIsHelpful(gulp) ? [].concat(name, desc, rest) : [].concat(name, rest);
return gulp.task.apply(gulp, _toConsumableArray(args));
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlLWdvb2RzLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7UUEyQmdCLE8sR0FBQSxPO1FBbUJBLFMsR0FBQSxTO1FBa0NBLFMsR0FBQSxTO1FBTUEsTSxHQUFBLE07UUFRQSxNLEdBQUEsTTtRQUlBLGEsR0FBQSxhO1FBSUEsVyxHQUFBLFc7UUFLQSxRLEdBQUEsUTs7QUEzR2hCOztBQUVBOzs7O0FBQ0E7Ozs7QUFDQTs7OztBQUNBOzs7O0FBQ0E7Ozs7QUFDQTs7Ozs7Ozs7QUFFTyxJQUFNLG9CQUFNLFFBQVEsZUFBSyxJQUFMLENBQVUsUUFBUSxHQUFSLEVBQVYs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