-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.js
41 lines (33 loc) · 836 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
'use strict';
var utils = require('lazy-cache')(require);
var fn = require;
require = utils;
/**
* Lazily required module dependencies
*/
require('extend-shallow', 'extend');
require('file-is-binary', 'isBinary');
require('gray-matter', 'matter');
require('mixin-deep', 'merge');
require('isobject', 'isObject');
require('trim-leading-lines', 'trim');
require = fn;
utils.isValidFile = function(file) {
file = file || {};
return !utils.isNull(file) && !utils.isBinary(file);
};
utils.hasYFM = function(file) {
return file.data && file.data.hasOwnProperty('yfm');
};
utils.isNull = function isNull(file) {
if (file && typeof file.isNull !== 'function') {
file.isNull = function() {
return file.contents === null;
};
}
return file.isNull();
};
/**
* Expose `utils` modules
*/
module.exports = utils;