gulp-files-to-json
Advanced tools
Comparing version 0.1.1 to 0.2.0
17
index.js
@@ -7,6 +7,14 @@ var through = require('through'); | ||
module.exports = function(file) { | ||
module.exports = function(file, options) { | ||
if (typeof options === 'undefined') { | ||
options = {}; | ||
} | ||
options.nameParser = options.nameParser || function(name) { | ||
path.basename(name).replace(path.extname(name), ''); | ||
}; | ||
if (typeof file !== 'string') { | ||
if (typeof file.path !== 'string') { | ||
throw new PluginError('gulp-concat', 'Missing path in file options for gulp-concat'); | ||
throw new PluginError('gulp-files-to-json', 'Missing path in file options for gulp-files-to-json'); | ||
} | ||
@@ -21,7 +29,8 @@ } | ||
} | ||
if (file.isStream()) { | ||
return this.emit('error', new PluginError('gulp-concat', 'Streaming not supported')); | ||
return this.emit('error', new PluginError('gulp-files-to-json', 'Streaming not supported')); | ||
} | ||
var name = path.basename(file.path).replace(path.extname(file.path), ''); | ||
var name = options.nameParser(file.path); | ||
fileMap[name] = file.contents.toString(); | ||
@@ -28,0 +37,0 @@ } |
{ | ||
"name": "gulp-files-to-json", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "*A really shitty gulp plugin to read a bunch of files and output a json file.*", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
2294
38