"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const genutils_1 = require("./genutils");
let waitForDoneAck = false;
function handleError(error) {
    genutils_1.ConnectionLogger.log(error);
    waitForDoneAck = true;
    process.send([]);
}
process.on('message', (index_file) => {
    if (waitForDoneAck) {
        process.exit();
    }
    else {
        try {
            genutils_1.fsExists(index_file)
                .then(() => {
                return genutils_1.fsReadFile(index_file);
            })
                .then((data) => {
                waitForDoneAck = true;
                process.send(JSON.parse(data));
            })
                .catch((error) => {
                handleError(error);
            });
        }
        catch (error) {
            handleError(error);
        }
    }
});
