Commit 6d043b6c authored by Alexey.Golubev's avatar Alexey.Golubev Committed by Alexander.Trofimov

Переделана схема загрузки изменений. Вместо пути к одному файлу, в скрипт...

Переделана схема загрузки изменений. Вместо пути к одному файлу, в скрипт передается путь к папке содержащей файламы изменений.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47973 954022d7-b5bf-4e40-9824-e11837661b57
parent 1bde183f
if(process.argv.length < 5)
{
console.log("Wrong parameter count!");
console.log("Usage: node merge.js <base_file_name> <changes_file_name> <output_file_name>");
console.log("Usage: node merge.js <base_file_name> <changes_dir_name> <output_file_name>");
return;
}
var base_file = process.argv[2];
var changes_file = process.argv[3];
var changes_dir = process.argv[3];
var output_file = process.argv[4];
setTimeout( main, 0, base_file, changes_file, output_file);
setTimeout( main, 0, base_file, changes_dir, output_file);
function main(base_file, changes_file, output_file)
function main(base_file, changes_dir, output_file)
{
var error_code = 1;
try {
......@@ -23,11 +23,23 @@ function main(base_file, changes_file, output_file)
var base_doc = fs.readFileSync(base_file, 'utf-8');
editor.LoadDocument( base_doc );
var doc_changes = require(changes_file);
var doc_changes = [];
var changes_file_array = fs.readdirSync(changes_dir);
for(var i in changes_file_array)
{
var changes_file_name = changes_file_array[i];
if(changes_file_name.match(/changes[\d]*.json/i))
{
var doc_changes_tmp = fs.readFileSync(changes_dir + "/" + changes_file_name, 'utf-8');
doc_changes_tmp = JSON.parse(doc_changes_tmp);
doc_changes = doc_changes.concat(doc_changes_tmp);
}
}
editor.ApplyChanges( doc_changes );
var changed_doc = editor.Save();
fs.writeFileSync(output_file, changed_doc, 'utf-8');/**/
fs.writeFileSync(output_file, changed_doc, 'utf-8');
//var TimeEnd = new Date();
//console.log("Execution duration:", TimeEnd - TimeStart, " ms.");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment