diff --git a/action.yml b/action.yml index 9cd7857..520852a 100644 --- a/action.yml +++ b/action.yml @@ -53,7 +53,8 @@ runs: with: result-encoding: string script: | - const exports = exports || {}; + const exports = {}; + function expose() { // SCRIPT REPLACE START "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); @@ -80,7 +81,9 @@ runs: } exports.main = main; // SCRIPT REPLACE END - await main(process.cwd(), context); + } + expose(); + await exports.main(process.cwd(), context); - name: Publish shell: bash diff --git a/scripts/replace-action.cjs b/scripts/replace-action.cjs index c96d2e7..ac0302e 100644 --- a/scripts/replace-action.cjs +++ b/scripts/replace-action.cjs @@ -8,8 +8,9 @@ const write = (f, d) => fs.writeFileSync(resolve(f), d, 'utf8'); const source = read('dist/index.cjs'); const action = read('action.yml'); const action2 = action.replace(/^(\s+)\/\/ SCRIPT REPLACE START[\s\S]*?^(\s+)\/\/ SCRIPT REPLACE END/m, (_, indent) => { + const source2 = source.trim().replace(/^/gm, indent); return `${indent}// SCRIPT REPLACE START -${source.trim().replace(/^/gm, indent)} +${source2} ${indent}// SCRIPT REPLACE END`; });