23 lines
696 B
TypeScript
23 lines
696 B
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
//
|
|
// Generate PACKAGE_VERSION module
|
|
//
|
|
|
|
const sourceDir = path.join(__dirname, "../src");
|
|
|
|
const { version: PACKAGE_VERSION, name: PACKAGE_NAME } = JSON.parse(
|
|
fs.readFileSync(path.join(__dirname, "../package.json"), "utf8"),
|
|
);
|
|
const versionFileName = path.join(sourceDir, "lib", "_version.ts");
|
|
const code = `// This file is auto-generated by the codegen maintenance script
|
|
export const PACKAGE_VERSION = "${PACKAGE_VERSION}";
|
|
export const PACKAGE_NAME = "${PACKAGE_NAME}";
|
|
`;
|
|
|
|
fs.writeFileSync(versionFileName, code, "utf8");
|