Skip to content

Commit 1eca777

Browse files
authored
Adds support for custom postinstall.js (#20)
* Adds support for custom postinstall.js * Update dist on Ubuntu and push
1 parent 3f0488a commit 1eca777

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ inputs:
2424
bundle-npm-artifacts-mode:
2525
description: Runs a steps that bundle artifacts for release the app to NPM.
2626
required: false
27+
postinstall-js:
28+
description: Path to a postinstall.js file that would be run by NPM
29+
required: false
2730
runs:
2831
using: node20
2932
main: dist/index.js

dist/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -175235,6 +175235,7 @@ const sourceCacheKey = core.getInput("source-cache-key");
175235175235
const manifestKey = core.getInput("manifest");
175236175236
const prepareNPMArtifactsMode = core.getInput("prepare-npm-artifacts-mode");
175237175237
const bundleNPMArtifactsMode = core.getInput("bundle-npm-artifacts-mode");
175238+
const customPostInstallJS = core.getInput("postinstall-js");
175238175239
function run(name, command, args) {
175239175240
return __awaiter(this, void 0, void 0, function* () {
175240175241
const PATH = process.env.PATH ? process.env.PATH : "";
@@ -175444,8 +175445,9 @@ function bundleNPMArtifacts() {
175444175445
catch (_a) {
175445175446
console.warn("No LICENSE found");
175446175447
}
175447-
console.log("Copying postinstall.js");
175448-
external_fs_.copyFileSync(__nccwpck_require__.ab + "release-postinstall.js", external_path_.join(releaseFolder, "postinstall.js"));
175448+
const releasePostInstallJS = customPostInstallJS !== null && customPostInstallJS !== void 0 ? customPostInstallJS : __nccwpck_require__.ab + "release-postinstall.js";
175449+
console.log("Copying postinstall.js from", releasePostInstallJS);
175450+
external_fs_.copyFileSync(releasePostInstallJS, external_path_.join(releaseFolder, "postinstall.js"));
175449175451
console.log("Creating placeholder files");
175450175452
const placeholderFile = `:; echo "You need to have postinstall enabled"; exit $?
175451175453
@ECHO OFF

index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const sourceCacheKey = core.getInput("source-cache-key");
1616
const manifestKey = core.getInput("manifest");
1717
const prepareNPMArtifactsMode = core.getInput("prepare-npm-artifacts-mode");
1818
const bundleNPMArtifactsMode = core.getInput("bundle-npm-artifacts-mode");
19+
const customPostInstallJS = core.getInput("postinstall-js");
1920

2021
async function run(name: string, command: string, args: string[]) {
2122
const PATH = process.env.PATH ? process.env.PATH : "";
@@ -287,9 +288,11 @@ async function bundleNPMArtifacts() {
287288
console.warn("No LICENSE found");
288289
}
289290

290-
console.log("Copying postinstall.js");
291+
const releasePostInstallJS =
292+
customPostInstallJS ?? path.join(__dirname, "release-postinstall.js");
293+
console.log("Copying postinstall.js from", releasePostInstallJS);
291294
fs.copyFileSync(
292-
path.join(__dirname, "release-postinstall.js"),
295+
releasePostInstallJS,
293296
path.join(releaseFolder, "postinstall.js")
294297
);
295298

0 commit comments

Comments
 (0)