mirror of
https://github.com/nasa/openmct.git
synced 2024-12-30 09:58:52 +00:00
39 lines
949 B
JavaScript
39 lines
949 B
JavaScript
// Temporary utility script to rewrite bundle.json
|
|
// files as bundle.js files.
|
|
|
|
var glob = require('glob'),
|
|
fs = require('fs'),
|
|
header = fs.readFileSync('header.txt', 'utf8');
|
|
|
|
function indent(str) {
|
|
return str.split('\n').map(function (line, index) {
|
|
return index === 0 ? line : (' ' + line);
|
|
}).join('\n');
|
|
}
|
|
|
|
function rebundle(file) {
|
|
var plainJson = fs.readFileSync(file, 'utf8'),
|
|
bundleName = file.replace("/bundle.json", ""),
|
|
outputFile = file.replace(".json", ".js"),
|
|
contents = [
|
|
header,
|
|
"legacyRegistry.register(\"",
|
|
bundleName,
|
|
"\", ",
|
|
indent(plainJson),
|
|
");\n",
|
|
"});\n"
|
|
].join('');
|
|
fs.writeFileSync(outputFile, contents, 'utf8');
|
|
}
|
|
|
|
glob('**/bundle.json', {}, function (err, files) {
|
|
if (err) {
|
|
console.log(err);
|
|
return;
|
|
}
|
|
|
|
files.forEach(rebundle);
|
|
});
|
|
|