mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
init
This commit is contained in:
27
packages/cli/src/commands/loads/loads.local.ts
Normal file
27
packages/cli/src/commands/loads/loads.local.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user