Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 35003a9906d49841ecaca71fb8d8a1ecd61c8a48 @marcooliveira marcooliveira committed Feb 26, 2013
Showing with 313 additions and 0 deletions.
  1. +58 −0 .gitignore
  2. +58 −0 .jshintrc
  3. +58 −0 .npmignore
  4. +42 −0 README.md
  5. +71 −0 autofile.js
  6. +26 −0 package.json
@@ -0,0 +1,58 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+Desktop.ini
+.Spotlight-V100
+.Trashes
+._*
+
+# NetBeans #
+############
+nbsettings/
+nbproject/
+nbbuild/
+nbdist/
+nbactions.xml
+nb-configuration.xml
+
+# Textmate #
+############
+*.tmproj
+*.tmproject
+tmtags
+
+# VIM #
+#######
+.*.sw[a-z]
+*.un~
+Session.vim
+
+# Sublime TextEditor #
+######################
+*.sublime-project
+
+# Eclipse #
+######################
+/.project
+/.settings
+
+# Node #
+######################
+node_modules
+npm-debug.*
+
+# Project specific #
+####################
+
@@ -0,0 +1,58 @@
+{
+ "predef": [
+ "console",
+ "require",
+ "define"
+ ],
+
+ "node": true,
+ "devel": true,
+
+ "bitwise": true,
+ "curly": true,
+ "eqeqeq": true,
+ "forin": false,
+ "immed": true,
+ "latedef": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": true,
+ "plusplus": false,
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "quotmark": "single",
+ "strict": true,
+ "trailing": true,
+
+ "asi": false,
+ "boss": false,
+ "debug": false,
+ "eqnull": true,
+ "es5": false,
+ "esnext": false,
+ "evil": false,
+ "expr": false,
+ "funcscope": false,
+ "globalstrict": false,
+ "iterator": false,
+ "lastsemic": false,
+ "laxbreak": false,
+ "laxcomma": false,
+ "loopfunc": true,
+ "multistr": false,
+ "onecase": true,
+ "regexdash": false,
+ "scripturl": false,
+ "smarttabs": false,
+ "shadow": false,
+ "sub": false,
+ "supernew": false,
+ "validthis": false,
+
+ "nomen": false,
+ "onevar": false,
+ "white": true
+}
+
@@ -0,0 +1,58 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+Desktop.ini
+.Spotlight-V100
+.Trashes
+._*
+
+# NetBeans #
+############
+nbsettings/
+nbproject/
+nbbuild/
+nbdist/
+nbactions.xml
+nb-configuration.xml
+
+# Textmate #
+############
+*.tmproj
+*.tmproject
+tmtags
+
+# VIM #
+#######
+.*.sw[a-z]
+*.un~
+Session.vim
+
+# Sublime TextEditor #
+######################
+*.sublime-project
+
+# Eclipse #
+######################
+/.project
+/.settings
+
+# Node #
+######################
+node_modules
+npm-debug.*
+
+# Project specific #
+####################
+
@@ -0,0 +1,42 @@
+`automaton task` - http://indigounited.com/automaton
+
+rm
+===
+
+Remove file or set of files.
+
+*Indigo United 2013*
+
+----------------------------------------
+
+## Introduction
+
+A more detailed description of what the task does. Avoid having code in here, unless necessary.
+
+
+## Requirements
+
+If your task requires something from the environment in which it runs that can't be guaranteed through `package.json`, you should mention it here, and give directions on how to get those installed (linking to another *"how to install"* is fine).
+
+
+## Usage
+
+A concise description of how to use the task. If the task can accomplish a lot, consider breaking this section into several subsections, each incrementing on the previous, possibly with multiple examples.
+
+### Options
+
+A list of the options that the task can get, and what they are for:
+
+- `option1`: This is option1!
+- `another_option`: This is another option.
+
+### Example
+
+```
+// Some example that shows how to use the task
+```
+
+
+## License
+
+Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
@@ -0,0 +1,71 @@
+/*jshint es5:true*/
+
+'use strict';
+
+var fs = require('fs'),
+ glob = require('glob'),
+ async = require('async'),
+ utils = require('mout'),
+ path = require('path'),
+ interp = require('../lib/string/interpolate')
+;
+
+var task = {
+ id : 'scaffolding-file-rename',
+ author : 'Indigo United',
+ name : 'Scaffolding: file rename.',
+ description : 'Replaces {{placeholders}} in a set of files.',
+ options: {
+ files: {
+ description: 'From which dir to start looking for files with placeholders. Accepts a dir and array of dirs. Also note that the dirs can be minimatch patterns.'
+ },
+ data: {
+ description: 'The data to be used while renaming. Keys are placeholder names and the values are the content for each placeholder.'
+ },
+ glob: {
+ description: 'The options to pass to glob (check https://npmjs.org/package/glob for details).',
+ default: null
+ }
+ },
+ tasks:
+ [
+ {
+ task: function (opt, ctx, next) {
+ var files = utils.lang.isArray(opt.files) ? opt.files : [opt.files];
+
+ // Do this in series, because it can give problems if the directories intersect eachother
+ async.forEachSeries(files, function (file, next) {
+ glob(file, opt.glob, function (err, matches) {
+ if (err) {
+ return next(err);
+ }
+
+ // Grab the list of files to rename
+ // Note that matches must be traversed backwards
+ var x;
+ var filesToRename = [];
+ var before;
+ var after;
+
+ for (x = matches.length - 1; x >= 0; --x) {
+ before = path.basename(matches[x]);
+ after = interp(before, opt.data);
+
+ if (before !== after) {
+ filesToRename.push({ before: matches[x], after: path.dirname(matches[x]) + '/' + after });
+ }
+ }
+
+ // Foreach file found, rename it (has to be in series)
+ async.forEachSeries(filesToRename, function (obj, next) {
+ ctx.log.debugln('Renaming from ' + obj.before + ' to ' + obj.after);
+ fs.rename(obj.before, obj.after, next);
+ }, next);
+ });
+ }, next);
+ }
+ }
+ ]
+};
+
+module.exports = task;
@@ -0,0 +1,26 @@
+{
+ "name": "autofile-scaffolding-file-rename",
+ "version": "0.0.1",
+ "description": "Replaces {{placeholders}} in a set of files.",
+ "main": "autofile.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/IU-Automaton/autofile-scaffolding-file-rename"
+ },
+ "keywords": [
+ "autofile",
+ "automaton",
+ "task",
+ "scaffolding",
+ "file",
+ "rename",
+ "glob",
+ "placeholder"
+ ],
+ "author": "Indigo United",
+ "license": "MIT",
+ "readmeFilename": "README.md"
+}

0 comments on commit 35003a9

Please sign in to comment.