mirror of
https://github.com/nasa/openmct.git
synced 2025-01-21 03:55:31 +00:00
[API] Add temporary bundle-rewriting script
This commit is contained in:
parent
612dd7db2c
commit
9ebafa157b
25
header.txt
Normal file
25
header.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*global define*/
|
||||||
|
|
||||||
|
define(['legacyRegistry'], function (legacyRegistry) {
|
||||||
|
"use strict";
|
38
rebundle.js
Normal file
38
rebundle.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user