UNPKG

@wesjet/function.js

Version:
24 lines (23 loc) 1.09 kB
import * as tracing_1 from "@effect-ts/core/Tracing"; const fileName_1 = "packages/@wesjet/function.js/src/node/version.ts"; /** * Copyright (c) Wesbitty, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; import { pipe, T } from '../effect/index.js'; import * as fs from './fs.js'; // TODO do this at compile time as this takes 10ms every time // use static import once JSON modules are no longer experimental // import utilsPkg from '@wesjet/function.js/package.json' const __dirname = path.dirname(fileURLToPath(import.meta.url)); export const getWesjetVersion = () => { // Go two levels up for "dist/node/version.js" const packageJsonFilePath = path.join(__dirname, '..', '..', 'package.json'); return (T.catchTag_(T.map_(fs.readFileJson(packageJsonFilePath), (pkg) => pkg.version, fileName_1 + ":29:10"), 'node.fs.FileNotFoundError', (e) => T.die(e, fileName_1 + ":30:57"), fileName_1 + ":30:15")); };