metalsmith-jstransformer
Advanced tools
Comparing version 0.5.0 to 0.5.1
# Changelog | ||
## v0.5.1 | ||
- Switch to minimatch for filtering files | ||
- Update dependencies | ||
## v0.5.0: 2015-07-11 | ||
@@ -4,0 +9,0 @@ |
47
index.js
var jstransformer = require('jstransformer') | ||
var toTransformer = require('inputformat-to-jstransformer') | ||
var path = require('path') | ||
var extend = require('extend') | ||
var async = require('async') | ||
var clone = require('clone') | ||
var match = require('minimatch').match | ||
var transformers = {} | ||
/** | ||
* Get the transformer from the given name. | ||
* | ||
* @return The JSTransformer; null if it doesn't exist. | ||
*/ | ||
* Get the transformer from the given name. | ||
* | ||
* @return The JSTransformer; null if it doesn't exist. | ||
*/ | ||
function getTransformer (name) { | ||
@@ -24,11 +25,9 @@ if (name in transformers) { | ||
module.exports = function (opts) { | ||
// Prepare the options. | ||
opts = opts || {} | ||
opts.pattern = opts.pattern || '[!_]*' | ||
// Execute the plugin. | ||
return function (files, metalsmith, done) { | ||
/** | ||
* Return whether or not we are to process the given file. | ||
*/ | ||
function filterFile (file, done) { | ||
done(path.basename(file).charAt(0) !== '_') | ||
} | ||
/** | ||
* Process the given file. Call done() when done processing. | ||
@@ -86,3 +85,3 @@ */ | ||
// See if we should add the default output format. | ||
if (files[file].jstransformer_filepath.length === 1) { | ||
if (files[file].jstransformer_filepath.length === 1 && files[file].jstransformer_outputFormat) { | ||
files[file].jstransformer_filepath.push(files[file].jstransformer_outputFormat) | ||
@@ -103,15 +102,15 @@ } | ||
// Filter out each file that we don't need to act on. | ||
async.filter(Object.keys(files), filterFile, function (results) { | ||
// Process each individual file. | ||
async.map(results, processFile, function (err) { | ||
if (err) { | ||
done(err) | ||
} else { | ||
// Now rename all the files. | ||
async.map(results, renameFile, done) | ||
} | ||
}) | ||
// Filter out all the files we are to ignore. | ||
var results = match(Object.keys(files), opts.pattern, { matchBase: true }) | ||
// Process each file. | ||
async.map(results, processFile, function (err) { | ||
if (err) { | ||
done(err) | ||
} else { | ||
// Now rename all the files. | ||
async.map(results, renameFile, done) | ||
} | ||
}) | ||
} | ||
} |
{ | ||
"name": "metalsmith-jstransformer", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Metalsmith JSTransformer Plugin", | ||
"main": "index.js", | ||
"files": [ | ||
@@ -30,3 +29,4 @@ "index.js" | ||
"inputformat-to-jstransformer": "^1.1.2", | ||
"jstransformer": "^0.0.2" | ||
"jstransformer": "0.0.*", | ||
"minimatch": "^2.0.8" | ||
}, | ||
@@ -33,0 +33,0 @@ "devDependencies": { |
8149
6
101
+ Addedminimatch@^2.0.8
+ Addedasap@2.0.6(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedjstransformer@0.0.4(transitive)
+ Addedminimatch@2.0.10(transitive)
+ Addedpromise@7.3.1(transitive)
- Removedasap@1.0.0(transitive)
- Removedjstransformer@0.0.2(transitive)
- Removedpromise@6.1.0(transitive)
Updatedjstransformer@0.0.*