Created
June 7, 2015 12:09
-
-
Save vyp/5f25b8648e9aef29f0f0 to your computer and use it in GitHub Desktop.
used for nylira/prism-break #1331
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var path = require('path'); | |
var _ = require('lodash'); | |
var glob = require('glob'); | |
var globOptions = { | |
'cwd' : './source/db/', | |
'mark' : true | |
}; | |
var files = glob | |
.sync('*.json', globOptions); | |
files.forEach(function(filename) { | |
var fp = globOptions.cwd + filename; | |
var f = require(fp); | |
fs.writeFile(fp, JSON.stringify(_.sortBy(f, 'slug'), null, 2), | |
function (e) { | |
if (e) { | |
console.log(e); | |
} | |
} | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment