@effected/xdg 0.8.0 → 0.8.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.
Files changed (2) hide show
  1. package/README.md +28 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -128,6 +128,34 @@ Order matters: put `resolver` before `nativeResolver` so an existing `~/.config/
128
128
 
129
129
  A namespace that is empty, or contains a path separator, or is exactly `.` or `..`, is a **defect** at layer construction rather than a typed error. It can only come from code, and `namespace: "../.."` would resolve the application's directories outside `$HOME` entirely.
130
130
 
131
+ ## Testing
132
+
133
+ `@effected/memfs` virtualizes the filesystem, not the platform. `AppDirs` and `XdgConfig` read the platform through the `CurrentPlatform` reference, which defaults to the host's `process.platform`, so a test that only swaps the filesystem still takes the host's darwin, linux or win32 branch. Pin the platform as well:
134
+
135
+ ```ts
136
+ import { MemoryFileSystem } from "@effected/memfs";
137
+ import { AppDirs, CurrentPlatform, Xdg, XdgPaths } from "@effected/xdg";
138
+ import { Effect, Layer, Path } from "effect";
139
+
140
+ const TestEnv = Layer.mergeAll(
141
+ Xdg.layerFrom(XdgPaths.make({ home: "/home/ada", configDirs: ["/etc/xdg"], dataDirs: ["/usr/share"] })),
142
+ MemoryFileSystem.layer,
143
+ Path.layer,
144
+ );
145
+
146
+ const config = Effect.gen(function* () {
147
+ const appDirs = yield* AppDirs;
148
+ return appDirs.dirs.config;
149
+ }).pipe(
150
+ Effect.provide(AppDirs.layer({ namespace: "myapp", native: true }).pipe(Layer.provide(TestEnv))),
151
+ Effect.provideService(CurrentPlatform, "linux"),
152
+ );
153
+ // "/home/ada/.myapp" on every host; pin "darwin" and the same program answers
154
+ // "/home/ada/Library/Application Support/myapp"
155
+ ```
156
+
157
+ `Layer.succeed(CurrentPlatform, "win32")` is the equivalent layer form, for composing the pin into a test layer graph.
158
+
131
159
  ## Features
132
160
 
133
161
  - `Xdg` / `XdgPaths` — the resolved XDG environment as a value, including the `$XDG_CONFIG_DIRS` and `$XDG_DATA_DIRS` search paths, split and defaulted per the spec. `Xdg.layerFrom` serves fixed paths for tests.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/xdg",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "private": false,
5
5
  "description": "XDG Base Directory resolution for Effect: environment paths, app-namespaced directories, native OS conventions and config-file resolvers.",
6
6
  "keywords": [
@@ -38,8 +38,8 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "peerDependencies": {
41
- "@effected/config-file": "^0.13.0",
42
- "@effected/walker": "^0.13.0",
41
+ "@effected/config-file": "^0.13.1",
42
+ "@effected/walker": "^0.14.0",
43
43
  "effect": "4.0.0-rc.118"
44
44
  },
45
45
  "engines": {