UNPKG

@hirosystems/api-toolkit

Version:
33 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SERVER_VERSION = void 0; exports.getServerVersion = getServerVersion; const node_fs_1 = require("node:fs"); const is_debugging_1 = require("../helpers/is-debugging"); function getServerVersion() { if (process.env.NODE_ENV === 'test') { return { branch: 'test', commit: '123456', tag: 'v0.0.1', }; } try { const [branch, commit, tag] = (0, node_fs_1.readFileSync)('.git-info', 'utf-8').split('\n'); return { branch, commit, tag }; } catch (error) { // If .git-info file does not exist and we are debugging, return a default version const fileNotExists = error.code === 'ENOENT'; if (fileNotExists && (0, is_debugging_1.isDebugging)()) { return { branch: 'debugging', commit: '123456', tag: 'v0.0.1', }; } throw error; } } exports.SERVER_VERSION = getServerVersion(); //# sourceMappingURL=index.js.map