Skip to content

Commit

Permalink
Adds support for custom postinstall.js (#20)
Browse files Browse the repository at this point in the history
* Adds support for custom postinstall.js

* Update dist on Ubuntu and push
  • Loading branch information
ManasJayanth authored Jun 12, 2024
1 parent 3f0488a commit 1eca777
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ inputs:
bundle-npm-artifacts-mode:
description: Runs a steps that bundle artifacts for release the app to NPM.
required: false
postinstall-js:
description: Path to a postinstall.js file that would be run by NPM
required: false
runs:
using: node20
main: dist/index.js
Expand Down
6 changes: 4 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175235,6 +175235,7 @@ const sourceCacheKey = core.getInput("source-cache-key");
const manifestKey = core.getInput("manifest");
const prepareNPMArtifactsMode = core.getInput("prepare-npm-artifacts-mode");
const bundleNPMArtifactsMode = core.getInput("bundle-npm-artifacts-mode");
const customPostInstallJS = core.getInput("postinstall-js");
function run(name, command, args) {
return __awaiter(this, void 0, void 0, function* () {
const PATH = process.env.PATH ? process.env.PATH : "";
Expand Down Expand Up @@ -175444,8 +175445,9 @@ function bundleNPMArtifacts() {
catch (_a) {
console.warn("No LICENSE found");
}
console.log("Copying postinstall.js");
external_fs_.copyFileSync(__nccwpck_require__.ab + "release-postinstall.js", external_path_.join(releaseFolder, "postinstall.js"));
const releasePostInstallJS = customPostInstallJS !== null && customPostInstallJS !== void 0 ? customPostInstallJS : __nccwpck_require__.ab + "release-postinstall.js";
console.log("Copying postinstall.js from", releasePostInstallJS);
external_fs_.copyFileSync(releasePostInstallJS, external_path_.join(releaseFolder, "postinstall.js"));
console.log("Creating placeholder files");
const placeholderFile = `:; echo "You need to have postinstall enabled"; exit $?
@ECHO OFF
Expand Down
7 changes: 5 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const sourceCacheKey = core.getInput("source-cache-key");
const manifestKey = core.getInput("manifest");
const prepareNPMArtifactsMode = core.getInput("prepare-npm-artifacts-mode");
const bundleNPMArtifactsMode = core.getInput("bundle-npm-artifacts-mode");
const customPostInstallJS = core.getInput("postinstall-js");

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

console.log("Copying postinstall.js");
const releasePostInstallJS =
customPostInstallJS ?? path.join(__dirname, "release-postinstall.js");
console.log("Copying postinstall.js from", releasePostInstallJS);
fs.copyFileSync(
path.join(__dirname, "release-postinstall.js"),
releasePostInstallJS,
path.join(releaseFolder, "postinstall.js")
);

Expand Down

0 comments on commit 1eca777

Please sign in to comment.