diff --git a/dist/main.js b/dist/main.js new file mode 100644 index 0000000..73f9654 --- /dev/null +++ b/dist/main.js @@ -0,0 +1,3 @@ +const index = require('./index.js'); + +index.main(); \ No newline at end of file diff --git a/dist/post.js b/dist/post.js new file mode 100644 index 0000000..0428f0b --- /dev/null +++ b/dist/post.js @@ -0,0 +1,3 @@ +const index = require('./index.js'); + +index.post(); \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index be8c89e..3047aa4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,30 +1,2 @@ -import { run as main } from './main'; -import path from 'path'; -import { run as post } from './post'; - -/* - * GitHub Action can provide multiple executable entrypoints (pre, main, post), - * but it is complicated process to generate multiple `.js` files with `ncc`. - * So we rather generate just one entrypoint, that is symlinked to multiple locations (main.js and post.js). - * Then when GitHub Action Runner executes it as `node path/to/main.js` and `node path/to/post.js`, - * it can read arguments it was executed with and decide which file to execute. - * The argv[0] is going to be a full path to `node` executable and - * the argv[1] is going to be the full path to the script. - * In case index.js would be marked executable and executed directly without the argv[1] it defaults to "main.js". - */ -async function run([, name = 'main.js']: string[]) { - const script = path.basename(name); - - switch (script) { - case 'main.js': - await main(); - break; - case 'post.js': - await post(); - break; - default: - throw new Error(`Unknown script argument: '${script}'`); - } -} - -run(process.argv); +export { run as main } from './main'; +export { run as post } from './post';