Skip to content

Commit

Permalink
Replace the junky string concat with a nicer .cjs prebuid script
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Apr 20, 2024
1 parent 6adc39c commit c65adbc
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ lib/**/*
# Nix builds
result

src/package.ts
src/version.generated.ts
4 changes: 2 additions & 2 deletions dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 0 additions & 48 deletions dist/package.d.ts

This file was deleted.

48 changes: 0 additions & 48 deletions dist/package.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/version.generated.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/version.generated.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"check-fmt": "prettier --check .",
"format": "prettier --write .",
"lint": "eslint src/**/*.ts",
"prebuild": "echo 'export const pkg =' > src/package.ts; cat package.json >> ./src/package.ts && prettier --write ./src/package.ts && eslint --fix ./src/package.ts",
"prebuild": "pnpm exec node ./scripts/prebuild.cjs",
"docs": "pnpm run prebuild && typedoc src/main.ts",
"all": "pnpm run prebuild && pnpm run format && pnpm run lint && pnpm run build"
},
Expand Down
7 changes: 7 additions & 0 deletions scripts/prebuild.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const fs = require("node:fs/promises");

const json = require("../package.json");
fs.writeFile(
"./src/version.generated.ts",
`export const version = "${json.version}";\n`,
);
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/
import * as ghActionsCorePlatform from "./actions-core-platform.js";
import * as correlation from "./correlation.js";
import { pkg } from "./package.js";
import * as platform from "./platform.js";
import { SourceDef, constructSourceParameters } from "./sourcedef.js";
import { version as pkg_version } from "./version.generated.js";
import * as actionsCache from "@actions/cache";
import * as actionsCore from "@actions/core";
import got, { Got } from "got";
Expand Down Expand Up @@ -121,7 +121,7 @@ export class IdsToolbox {

this.facts = {
$lib: "idslib",
$lib_version: pkg.version,
$lib_version: pkg_version,
project: this.actionOptions.name,
ids_project: this.actionOptions.idsProjectName,
};
Expand Down

0 comments on commit c65adbc

Please sign in to comment.