(input: {
hostname: string;
port: number;
pid: number;
scopeId: string;
scopeDir: string | null;
token: string;
})
| 236 | }); |
| 237 | |
| 238 | export const writeDaemonPointer = (input: { |
| 239 | hostname: string; |
| 240 | port: number; |
| 241 | pid: number; |
| 242 | scopeId: string; |
| 243 | scopeDir: string | null; |
| 244 | token: string; |
| 245 | }): Effect.Effect<void, PlatformError, FileSystem.FileSystem | Path.Path> => |
| 246 | Effect.gen(function* () { |
| 247 | const fs = yield* FileSystem.FileSystem; |
| 248 | const path = yield* Path.Path; |
| 249 | const dataDir = resolveDaemonDataDir(path); |
| 250 | yield* fs.makeDirectory(dataDir, { recursive: true }); |
| 251 | |
| 252 | const payload: DaemonPointer = { |
| 253 | version: 1, |
| 254 | hostname: canonicalDaemonHost(input.hostname), |
| 255 | port: input.port, |
| 256 | pid: input.pid, |
| 257 | startedAt: new Date().toISOString(), |
| 258 | scopeId: input.scopeId, |
| 259 | scopeDir: input.scopeDir, |
| 260 | token: input.token, |
| 261 | }; |
| 262 | |
| 263 | yield* fs.writeFileString( |
| 264 | daemonPointerPath(path, { hostname: input.hostname, scopeId: input.scopeId }), |
| 265 | `${JSON.stringify(payload, null, 2)}\n`, |
| 266 | ); |
| 267 | }); |
| 268 | |
| 269 | export const readDaemonPointer = (input: { |
| 270 | hostname: string; |
no test coverage detected