Skip to content

Commit e769db2

Browse files
fix: reuse feature list for CLI, add 'fetch-event' (#269)
1 parent 86b1f90 commit e769db2

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/cli.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#! /usr/bin/env node
22

33
import { program, Option } from 'commander';
4-
import { componentize } from "./componentize.js";
4+
import { componentize, DEFAULT_FEATURES } from './componentize.js';
55
import { writeFile } from 'node:fs/promises';
66
import { resolve } from 'node:path';
77

8-
export async function componentizeCmd (jsSource, opts) {
9-
const { component } = await componentize( {
8+
export async function componentizeCmd(jsSource, opts) {
9+
const { component } = await componentize({
1010
sourcePath: jsSource,
1111
witPath: resolve(opts.wit),
1212
worldName: opts.worldName,
@@ -30,20 +30,29 @@ program
3030
.option('-n, --world-name <name>', 'WIT world to build')
3131
.option('--runtime-args <string>', 'arguments to pass to the runtime')
3232
.option('--aot', 'enable AOT compilation')
33-
.addOption(new Option('-d, --disable <feature...>', 'disable WASI features').choices(['stdio', 'random', 'clocks', 'http']))
34-
.option('--preview2-adapter <adapter>', 'provide a custom preview2 adapter path')
33+
.addOption(
34+
new Option('-d, --disable <feature...>', 'disable WASI features').choices(
35+
DEFAULT_FEATURES,
36+
),
37+
)
38+
.option(
39+
'--preview2-adapter <adapter>',
40+
'provide a custom preview2 adapter path',
41+
)
3542
.option('--use-debug-build', 'use a debug build of StarlingMonkey')
3643
.option('--debug-bindings', 'enable debug logging for bindings generation')
37-
.option('--enable-wizer-logging', 'enable debug logging for calls in the generated component')
44+
.option(
45+
'--enable-wizer-logging',
46+
'enable debug logging for calls in the generated component',
47+
)
3848
.requiredOption('-o, --out <out>', 'output component file')
3949
.action(asyncAction(componentizeCmd));
4050

41-
4251
program.showHelpAfterError();
4352

4453
program.parse();
4554

46-
function asyncAction (cmd) {
55+
function asyncAction(cmd) {
4756
return function () {
4857
const args = [...arguments];
4958
(async () => {

src/componentize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const DEFAULT_DEBUG_SETTINGS = {
6161
};
6262

6363
/** Features that are used by default if not explicitly disabled */
64-
const DEFAULT_FEATURES = ['stdio', 'random', 'clocks', 'http', 'fetch-event'];
64+
export const DEFAULT_FEATURES = ['stdio', 'random', 'clocks', 'http', 'fetch-event'];
6565

6666
export async function componentize(
6767
opts,

0 commit comments

Comments
 (0)