Skip to content

Instantly share code, notes, and snippets.

@fiznool
Created September 9, 2014 11:19
Show Gist options
  • Save fiznool/b4fe3e345beeba81e3a3 to your computer and use it in GitHub Desktop.
Save fiznool/b4fe3e345beeba81e3a3 to your computer and use it in GitHub Desktop.
Converts a directory of JSON files to JS ones.
'use strict';
var util = require('util'),
fs = require('fs');
var path = './server/services/defs';
var dirs = fs.readdirSync(path);
dirs.forEach(function(dir) {
var servicePath = path + '/' + dir;
var config = require(servicePath + '/config.json');
fs.writeFileSync(servicePath + '/config.js', 'module.exports = ' + util.inspect(config, { depth: null }) + ';');
});
process.exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment