just-bash 2.10.0 → 2.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,6 +74,22 @@ const env = new Bash({
74
74
  await env.exec("echo $TEMP", { env: { TEMP: "value" }, cwd: "/tmp" });
75
75
  ```
76
76
 
77
+ #### Lazy Files
78
+
79
+ File values can be functions (sync or async). The function is called on first read and the result is cached — if the file is written to before being read, the function is never called:
80
+
81
+ ```typescript
82
+ const env = new Bash({
83
+ files: {
84
+ "/data/config.json": () => JSON.stringify({ key: "value" }),
85
+ "/data/remote.txt": async () => (await fetch("https://example.com")).text(),
86
+ "/data/static.txt": "always loaded",
87
+ },
88
+ });
89
+ ```
90
+
91
+ This is useful for large or expensive-to-compute content that may not be needed.
92
+
77
93
  ### Custom Commands
78
94
 
79
95
  Extend just-bash with your own TypeScript commands using `defineCommand`: