vrem
Version:
An open-source automatic time-tracker
33 lines (32 loc) • 1.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const colors_1 = __importDefault(require("../colors"));
const child_process_1 = __importDefault(require("child_process"));
const fs_1 = __importDefault(require("fs"));
const process_1 = require("../process");
const constants_1 = __importDefault(require("../constants"));
const hasBinary = fs_1.default.existsSync('./dist_native/vrem_windows.node')
&& process.platform === 'win32' && process.arch === 'x64';
if (hasBinary) {
console.info(colors_1.default.green('\nPrebuilt binary is detected. No compilation is required.\n'));
}
else {
void compile();
}
async function compile() {
const alive = await (0, process_1.isProcessAlive)(constants_1.default.autoTrackerSocketPath);
if (alive) {
await (0, process_1.stopProcess)(process_1.trackerProcessName, constants_1.default.autoTrackerSocketPath);
}
console.info(colors_1.default.cyan('\nNo prebuilt binary. Trying to compile...\n'));
child_process_1.default.execSync('node-gyp rebuild', {
stdio: "inherit",
});
console.info(colors_1.default.green('\nCompilation succeeded.\n'));
if (alive) {
await (0, process_1.startProcess)(process_1.trackerProcessName, process_1.trackerScriptPath, constants_1.default.autoTrackerSocketPath);
}
}