Skip to content

Commit

Permalink
feat: add experiments config option (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerdav authored Aug 1, 2024
1 parent 5c1d569 commit 20ab2b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
"type": "string",
"default": "",
"description": "Set to a value such as localhost:7474 to enable a HTTP endpoint that can be used for debugging (same as the templ -http argument)"
},
"templ.experiments": {
"type": "string",
"default": "",
"description": "A comma separated list of enabled experiments e.g. \"experimentfoo,experimentbar\" (same as the TEMPL_EXPERIMENT environment variable)"
}
}
},
Expand Down
10 changes: 10 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface Configuration {
log: string;
pprof: boolean;
http: string;
experiments: string;
}

interface TemplCtx {
Expand All @@ -57,6 +58,7 @@ const loadConfiguration = (): Configuration => {
log: c.get("log") || "",
pprof: c.get("pprof") ? true : false,
http: c.get("http") || "",
experiments: c.get("experiments") || "",
};
};

Expand Down Expand Up @@ -155,11 +157,19 @@ export async function buildLanguageClient(): Promise<LanguageClient> {
3000
);

const envTemplExperiments = process.env.TEMPL_EXPERIMENT;
const templExperiments = config.experiments === "" ? envTemplExperiments : config.experiments;
const c = new CustomLanguageClient(
"templ", // id
"templ",
{
command: templPath,
options: {
env:{
...process.env,
TEMPL_EXPERIMENT: templExperiments,
},
},
args,
},
{
Expand Down

0 comments on commit 20ab2b8

Please sign in to comment.