Skip to content

Commit 8ddba62

Browse files
committed
modify containerEnv programmatically
1 parent 830504a commit 8ddba62

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/create-llama/helpers/devcontainer.ts

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function renderDevcontainerContent(
1111
fs.readFileSync(path.join(templatesDir, "devcontainer.json"), "utf8"),
1212
);
1313

14+
// Modify postCreateCommand
1415
if (frontend) {
1516
devcontainerJson.postCreateCommand =
1617
framework === "fastapi"
@@ -20,6 +21,22 @@ function renderDevcontainerContent(
2021
devcontainerJson.postCreateCommand =
2122
framework === "fastapi" ? "poetry install" : "npm install";
2223
}
24+
25+
// Modify containerEnv
26+
if (framework === "fastapi") {
27+
if (frontend) {
28+
devcontainerJson.containerEnv = {
29+
...devcontainerJson.containerEnv,
30+
PYTHONPATH: "${PYTHONPATH}:${workspaceFolder}/backend",
31+
};
32+
} else {
33+
devcontainerJson.containerEnv = {
34+
...devcontainerJson.containerEnv,
35+
PYTHONPATH: "${PYTHONPATH}:${workspaceFolder}",
36+
};
37+
}
38+
}
39+
2340
return JSON.stringify(devcontainerJson, null, 2);
2441
}
2542

packages/create-llama/templates/devcontainer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
}
3030
},
3131
"containerEnv": {
32-
"POETRY_VIRTUALENVS_CREATE": "false",
33-
"PYTHONPATH": "${PYTHONPATH}:${workspaceFolder}/backend"
32+
"POETRY_VIRTUALENVS_CREATE": "false"
3433
},
3534
"forwardPorts": [3000, 8000]
3635
}

0 commit comments

Comments
 (0)