mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
28 lines
725 B
TypeScript
28 lines
725 B
TypeScript
import { Command } from 'commander';
|
|
import { resolve } from 'path';
|
|
import { run } from '@morten-olsen/mini-loader-runner';
|
|
import { bundle } from '../../bundler/bundler.js';
|
|
|
|
const local = new Command('local');
|
|
|
|
local.argument('script').action(async (script) => {
|
|
const location = resolve(script);
|
|
const code = await bundle({ entry: location });
|
|
const { promise, emitter } = await run({
|
|
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 { local };
|