Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use glob and fs instead of Grunt, fixes #2 #7

Merged
merged 1 commit into from
Jun 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
before_install: npm install -g npm
language: node_js
node_js:
- "0.10"
Expand Down
21 changes: 14 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
"async": "0.2.9",
"wrench": "1.5.1",
"lodash": "~2.4.1",
"grunt": "~0.4.5"
"glob": "~4.0.2"
},
"devDependencies": {
"glob": "~3.2.9",
"mocha": "~1.18.2",
"jshint": "~2.4.4",
"chai": "~1.9.1"
Expand Down