Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/prepare_package_upload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as fs from "node:fs";
import * as os from "node:os";

import packageSpec from "rescript/package.json" with { type: "json" };
const packageSpec = JSON.parse(
fs.readFileSync(new URL("../../package.json", import.meta.url), "utf-8")
);

const { version } = packageSpec;

Expand Down
8 changes: 6 additions & 2 deletions cli/rescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// and its content are file/directories with regard to project root

import * as tty from "node:tty";
import packageJson from "rescript/package.json" with { type: "json" };
import * as fs from "node:fs";

import { bsc_exe, rescript_exe } from "./common/bins.js";
import * as bsb from "./common/bsb.js";
Expand Down Expand Up @@ -93,7 +93,11 @@ if (
) {
console.log(helpMessage);
} else if (argPatterns.version.includes(args[0])) {
console.log(packageJson.version);
const packageSpec = JSON.parse(
fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8")
);

console.log(packageSpec.version);
} else if (firstPositionalArgIndex !== -1) {
const subcmd = args[firstPositionalArgIndex];
const subcmdArgs = args.slice(firstPositionalArgIndex + 1);
Expand Down
7 changes: 5 additions & 2 deletions scripts/prebuilt.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import assert from "node:assert";
import fs from "node:fs";
import packageJson from "rescript/package.json" with { type: "json" };
import semver from "semver";
import { compilerVersionFile } from "#dev/paths";

Expand All @@ -29,7 +28,11 @@ assert.ok(bsVersionMatch, "Failed to parse the compiler version file");
const bsVersion = semver.parse(bsVersionMatch.version);
assert.ok(bsVersion, "Failed to parse the compiler version file");

const packageVersion = semver.parse(packageJson.version);
const packageSpec = JSON.parse(
fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"),
);

const packageVersion = semver.parse(packageSpec.version);
assert.ok(packageVersion, "Failed to parse the version of the package.json");

assert.ok(
Expand Down
4 changes: 3 additions & 1 deletion scripts/setVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// @ts-check

import fs from "node:fs";
import packageSpec from "rescript/package.json" with { type: "json" };

const packageSpec = JSON.parse(
fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"),
);
const { name, version } = packageSpec;

const stdlibPackageSpec = JSON.parse(
Expand Down
Loading