Skip to content

Commit

Permalink
Bye built in tasks! They now are in their own repositories.
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Mar 2, 2013
1 parent 56294b4 commit 42a957c
Show file tree
Hide file tree
Showing 28 changed files with 37 additions and 3,963 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -10,7 +10,7 @@
- Minor bug fixes and improvements
- Add a task builder to create tasks programatically
- Split built-in tasks into their own repository
- Add `context.string` with the lib/string functions
- Add `context.string` with the `lib/string` functions

## 0.1.4 - 2013-02-06

Expand Down
29 changes: 0 additions & 29 deletions base_autofile.js

This file was deleted.

44 changes: 19 additions & 25 deletions index.js
Expand Up @@ -5,7 +5,7 @@ var d = require('dejavu'),
fs = require('fs'),
assert = require('assert'),
async = require('async'),
path = require('path'),
glob = require('glob'),
promptly = require('promptly'),
inter = require('./lib/string/interpolate'),
castInter = require('./lib/string/cast-interpolate'),
Expand Down Expand Up @@ -34,15 +34,17 @@ var Automaton = d.Class.declare({
* @param {Object} [$options] The options
*/
initialize: function ($options) {
var errors;

this._options = $options;

// load core tasks
errors = this.loadTasks(__dirname + '/tasks');
if (errors.length) {
throw new Error(errors[0]);
}
var dirs = glob.sync(__dirname + '/node_modules/autofile-*');

dirs.forEach(function (dir) {
var errors = this.loadTasks(dir, 'autofile.js');
if (errors.length) {
throw new Error(errors[0]);
}
}, this);
},

/**
Expand Down Expand Up @@ -105,35 +107,27 @@ var Automaton = d.Class.declare({
* If the folder contain tasks that are not valid, it results in an error being pushed to
* an array. That array is returned by the function.
*
* @param {String} folder The folder to search for tasks
* @param {String} folder The folder to search for tasks
* @param {String} pattern The pattern to use when searching for files, defaults to '*.js'
*
* @return {Array} An array of errors
*/
loadTasks: function (folder) {
loadTasks: function (folder, pattern) {
assert(utils.lang.isString(folder), 'Expected folder to be a string');

pattern = pattern || '*.js';
folder = fs.realpathSync(folder) + '/';

var filenames = fs.readdirSync(folder),
file,
i,
errors = []
;

for (i = filenames.length - 1; i >= 0; --i) {
file = filenames[i];

// skip files that do not have a .js extension
if (path.extname(file) !== '.js') {
continue;
}
var filenames = glob.sync(folder + '/' + pattern),
errors = [];

filenames.forEach(function (file) {
try {
this.addTask(require(folder + file));
this.addTask(require(file));
} catch (e) {
errors.push(new Error('Unable to add task "' + folder + file + '": ' + e.message));
errors.push(new Error('Unable to add task "' + file + '": ' + e.message));
}
}
}, this);

return errors;
},
Expand Down
17 changes: 13 additions & 4 deletions package.json
Expand Up @@ -41,16 +41,25 @@
"dejavu": "~0.3.1",
"mout": "~0.3.0",
"colors": "~0.6.0-1",
"mkdirp": "~0.3.4",
"fstream": "~0.1.19",
"rimraf": "~2.0.2",
"optimist": "~0.3.5",
"glob": "3.1.15",
"update-notifier": "~0.1.2",
"promptly": "~0.1.0",
"autofile-chmod": "~0.0.0"
"autofile-chmod": "~0.0.0",
"autofile-cp": "~0.0.0",
"autofile-init": "~0.0.0",
"autofile-mkdir": "~0.0.0",
"autofile-mv": "~0.0.0",
"autofile-rm": "~0.0.0",
"autofile-run": "~0.0.0",
"autofile-scaffolding-append": "~0.0.0",
"autofile-scaffolding-close": "~0.0.0",
"autofile-scaffolding-file-rename": "~0.0.0",
"autofile-scaffolding-replace": "~0.0.0",
"autofile-symlink": "~0.0.0"
},
"devDependencies": {
"rimraf": "~2.0.2",
"expect.js": "~0.2.0",
"mocha": "~1.7.3",
"grunt": "~0.4.0",
Expand Down
62 changes: 0 additions & 62 deletions tasks/chmod.js

This file was deleted.

0 comments on commit 42a957c

Please sign in to comment.