This commit is contained in:
Morten Olsen
2024-01-12 12:43:51 +01:00
commit 6d8e5bf955
109 changed files with 9246 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import { Command } from 'commander';
import { resolve } from 'path';
import { run as runLoad } from '@morten-olsen/mini-loader-runner';
import { bundle } from '../../bundler/bundler.js';
import { step } from '../../utils/step.js';
const run = new Command('run');
run
.option('-ai, --auto-install', 'Auto install dependencies', false)
.argument('script')
.action(async (script) => {
const location = resolve(script);
const { autoInstall } = run.opts();
const code = await step('Bundling', async () => {
return await bundle({ entry: location, autoInstall });
});
const { promise, emitter } = await runLoad({
script: code,
});
emitter.addListener('message', (message) => {
switch (message.type) {
case 'log':
console.log(message.payload);
break;
case 'artifact:create':
console.log('artifact:create', message.payload.name);
break;
}
});
await promise;
});
export { run };