-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
57 lines (48 loc) · 950 Bytes
/
utils.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
'use strict';
var utils = require('lazy-cache')(require);
var fn = require;
require = utils;
/**
* Lazily required module dependencies
*/
require('arr-diff', 'diff');
require('arr-union', 'union');
require('define-property', 'define');
require('expand-args');
require('extend-shallow', 'extend');
require('is-registered');
require('is-valid-instance');
require = fn;
/**
* Utils
*/
utils.isValid = function(app, prop) {
if (!utils.isValidInstance(app)) {
return false;
}
if (utils.isRegistered(app, 'base-argv')) {
return false;
}
return true;
};
/**
* Cast the given `value` to an array.
*
* ```js
* utils.arrayify('foo');
* //=> ['foo']
*
* utils.arrayify(['foo']);
* //=> ['foo']
* ```
* @param {String|Array} `value`
* @return {Array}
* @api public
*/
utils.arrayify = function(val) {
return val ? (Array.isArray(val) ? val : [val]) : [];
};
/**
* Expose `utils` modules
*/
module.exports = utils;