Closed jerrytk closed 10 years ago
@jerrytk Thanks for taking the time to create this pull request.
Unfortunately this cannot be merged because it may potentially generate issues in the future and the feature implemented is not entirely configurable through the options object.
The name of the processed file (without extension) is used to generate the output - it's the case for jsonp
and js
format values. It's highly possible - I do this myself - that someone will include a dash in the file name or have the file name start with a number. This will make the output be invalid JavaScript code.
Another thing I'm not sure about is if the new formats are really needed or not. Could you provide a use case for them, please?
Regarding use case: I was using grunt-properties package for storing configuration data in .properties files and concatenating them after conversion. Now I am learning Gulp and thought it would be good to have similar tool for more useful YAML format.
(See relevant tool also here http://www.nczonline.net/blog/2011/12/20/introducing-props2js/ )
You are right about filenames, I didn't think about it before.
There are some ways of accomplishing that, but doing more than just a plugin call. event-stream package provides a map
function than can transform the output of the gulp-yaml plugin. For a different file name, gulp-rename can help too.
Added option format for selecting output file format. JSON stays as default, new formats are JSONP (JSON with padding), which returns the JSON structure wrapped in a function and JS where JSON object is assigned to a variable.