Use glob and fs instead of Grunt, fixes #2

This commit is contained in:
Mark Dalgleish
2014-06-24 10:40:24 +10:00
parent 2824fd7ee9
commit b190a605bb
3 changed files with 16 additions and 9 deletions

View File

@@ -1,9 +1,10 @@
var path = require('path');
var fs = require('fs');
var Q = require('q');
var wrench = require('wrench');
var _ = require('lodash');
var grunt = require('grunt');
var glob = require('glob');
var pkg = require('../package.json');
var git = require('./git');
@@ -70,23 +71,29 @@ exports.publish = function publish(config, done) {
// override defaults with any task options
var options = _.extend({}, defaults, config);
if (!grunt.file.isDir(options.base)) {
done(new Error('The "base" option must be an existing directory'));
try {
if (!fs.statSync(options.base).isDirectory()) {
done(new Error('The "base" option must be an existing directory'));
return;
}
} catch (err) {
done(err);
return;
}
var files = grunt.file.expand({
filter: 'isFile',
var files = glob.sync(options.src, {
cwd: options.base,
dot: options.dotfiles
}, options.src);
}).filter(function(file) {
return !fs.statSync(path.join(options.base, file)).isDirectory();
});
if (!Array.isArray(files) || files.length === 0) {
done(new Error('Files must be provided in the "src" property.'));
return;
}
var only = grunt.file.expand({cwd: options.base}, options.only);
var only = glob.sync(options.only, {cwd: options.base});
function log(message) {
if (!options.silent) {