Files

102 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2025-12-25 11:16:59 +01:00
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft,
https://unifyjs.org
*/
var fs = require('fs');
var factory = require('./api_example.js');
//var parser = require('args-parser');
var path = require('path');
const util = require('util');
const fse = require('fs');
const fast = util.promisify(factory);
var commandLineArguments = process.argv;
for (var i = 0; i < commandLineArguments.length; i++) {
var row = commandLineArguments[i]
if(row.includes("file")) {
var file = row.split("=")[1];
}
if(row.includes("index")) {
var index = row.split("=")[1];
}
}
var filePath = file;
var source = fs.readFileSync(filePath, "utf8")
var inputFiles = JSON.parse(source);
var i = index;
var batchSize = 70;
class gppWrapper{
constructor() {
}
async initialise() {
this.instance = await new factory();
}
async convert( inputFiles, i ) {
if( !this.instance ) {
await this.initialise();
}
let init_esm = this.instance.cwrap( 'init_esm', null, null );
let updateCodeFunction = this.instance.cwrap( 'updateCode', null, [ 'int','string', 'string', 'int' ]);
init_esm();
var n = i * batchSize;
updateCodeFunction( inputFiles.length, inputFiles );
console.log( "Processed", batchSize, "files" );
return true;
}
}
var gppInstance = new gppWrapper();
gppInstance.convert( inputFiles, i )