embark-area-51/lib/utils.js

36 lines
813 B
JavaScript
Raw Normal View History

2017-02-18 14:10:01 -05:00
var path = require('path');
2017-02-18 14:37:07 -05:00
var grunt = require('grunt');
2017-02-18 14:45:57 -05:00
var merge = require('merge');
2017-02-18 15:27:08 -05:00
var request = require('request');
2017-02-18 14:10:01 -05:00
function joinPath() {
return path.join.apply(path.join, arguments);
}
2017-02-18 14:45:57 -05:00
function filesMatchingPattern(files) {
2017-02-18 14:37:07 -05:00
return grunt.file.expand({nonull: true}, files);
}
function fileMatchesPattern(patterns, intendedPath) {
return grunt.file.isMatch(patterns, intendedPath);
}
2017-02-18 14:45:57 -05:00
function recursiveMerge(target, source) {
return merge.recursive(target, source);
}
2017-02-18 15:27:08 -05:00
function checkIsAvailable(url, callback) {
request(url, function(error, response, body) {
callback(!error);
});
}
2017-02-18 14:10:01 -05:00
module.exports = {
2017-02-18 14:45:57 -05:00
joinPath: joinPath,
filesMatchingPattern: filesMatchingPattern,
fileMatchesPattern: fileMatchesPattern,
2017-02-18 15:27:08 -05:00
recursiveMerge: recursiveMerge,
checkIsAvailable: checkIsAvailable
2017-02-18 14:10:01 -05:00
};