Update entrypoint scripts for windows runner

pull/257/head
Sokuhatiku 2024-01-05 00:22:23 +09:00
parent 5aafc5e074
commit e23ab9e3f6
3 changed files with 8 additions and 30 deletions

3
dist/main.js vendored 100644
View File

@ -0,0 +1,3 @@
const index = require('./index.js');
index.main();

3
dist/post.js vendored 100644
View File

@ -0,0 +1,3 @@
const index = require('./index.js');
index.post();

View File

@ -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';