mirror of
https://github.com/actions/github-script.git
synced 2026-04-08 07:00:05 +00:00
chore: Change back to the function-style operation
We lose the more normal looking export in favor of the `return` statement already traditional to this action, and thus can handle await statements without an ESM conversion. This is a separate commit from the former because I think the next major version of this action should switch to ESM, revert this commit, and use the more standard export notation in all supported languages.
This commit is contained in:
parent
d3f9a3b3fb
commit
f27b40e6b7
4 changed files with 28 additions and 51 deletions
29
dist/index.js
vendored
29
dist/index.js
vendored
|
|
@ -213408,21 +213408,23 @@ var io = __nccwpck_require__(7436);
|
|||
var dist_node = __nccwpck_require__(8883);
|
||||
// EXTERNAL MODULE: ./node_modules/@octokit/plugin-retry/dist-node/index.js
|
||||
var plugin_retry_dist_node = __nccwpck_require__(6298);
|
||||
;// CONCATENATED MODULE: external "node:vm"
|
||||
const external_node_vm_namespaceObject = require("node:vm");
|
||||
// EXTERNAL MODULE: ./node_modules/typescript/lib/typescript.js
|
||||
var typescript = __nccwpck_require__(7414);
|
||||
;// CONCATENATED MODULE: ./src/async-function.ts
|
||||
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor;
|
||||
function callAsyncFunction(args, source) {
|
||||
const fn = new AsyncFunction(...Object.keys(args), source);
|
||||
return fn(...Object.values(args));
|
||||
const commonJsArgs = {
|
||||
...args,
|
||||
module: { exports: {} },
|
||||
exports: {}
|
||||
};
|
||||
const fn = new AsyncFunction(...Object.keys(commonJsArgs), source);
|
||||
return fn(...Object.values(commonJsArgs));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/interpret-script.ts
|
||||
|
||||
|
||||
|
||||
var SupportedLanguage;
|
||||
(function (SupportedLanguage) {
|
||||
SupportedLanguage["cjs"] = "cjs";
|
||||
|
|
@ -213431,31 +213433,20 @@ var SupportedLanguage;
|
|||
})(SupportedLanguage || (SupportedLanguage = {}));
|
||||
async function interpretScript(language, context, script) {
|
||||
switch (language) {
|
||||
case SupportedLanguage.cjs:
|
||||
return async () => callAsyncFunction(context, script);
|
||||
case SupportedLanguage.cts:
|
||||
case SupportedLanguage.mts: {
|
||||
const fileName = `github-script.${language}`;
|
||||
const compilerResult = (0,typescript.transpileModule)(script, {
|
||||
script = (0,typescript.transpileModule)(script, {
|
||||
compilerOptions: {
|
||||
module: typescript.ModuleKind.CommonJS,
|
||||
target: typescript.ScriptTarget.Latest,
|
||||
strict: true
|
||||
},
|
||||
fileName
|
||||
});
|
||||
return async () => {
|
||||
const runContext = {
|
||||
module: { exports: {} },
|
||||
exports: {},
|
||||
process,
|
||||
...context
|
||||
};
|
||||
const runResult = external_node_vm_namespaceObject.runInNewContext(compilerResult.outputText, runContext);
|
||||
return runResult;
|
||||
};
|
||||
}).outputText;
|
||||
}
|
||||
}
|
||||
return async () => callAsyncFunction(context, script);
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/retry-options.ts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue