| ... | ... | @@ -159,6 +159,95 @@ it.effect("launches an installed editor with platform-safe arguments", () => |
| 159 | 159 | }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), |
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | for (const platform of ["darwin", "linux"] as const) { |
| 163 | it.effect.skipIf(windowsHost)(`launches Cursor in classic IDE mode on ${platform}`, () => |
| 164 | Effect.gen(function* () { |
| 165 | const fileSystem = yield* FileSystem.FileSystem; |
| 166 | const path = yield* Path.Path; |
| 167 | const binDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-editors-" }); |
| 168 | const cursorPath = path.join(binDir, "cursor"); |
| 169 | yield* fileSystem.writeFileString(cursorPath, "#!/bin/sh\n"); |
| 170 | yield* fileSystem.chmod(cursorPath, 0o755); |
| 171 | |
| 172 | const spawned: ChildProcess.StandardCommand[] = []; |
| 173 | yield* Effect.gen(function* () { |
| 174 | const launcher = yield* ExternalLauncher.ExternalLauncher; |
| 175 | for (const cwd of [ |
| 176 | "/workspace with spaces", |
| 177 | "/workspace with spaces/src/index.ts", |
| 178 | "/workspace with spaces/src/index.ts:12", |
| 179 | "/workspace with spaces/src/index.ts:12:4", |
| 180 | ]) { |
| 181 | yield* launcher.launchEditor({ editor: "cursor", cwd }); |
| 182 | } |
| 183 | }).pipe( |
| 184 | Effect.provide( |
| 185 | testLayer({ |
| 186 | platform, |
| 187 | env: { PATH: binDir }, |
| 188 | onSpawn: (command) => spawned.push(command), |
| 189 | }), |
| 190 | ), |
| 191 | ); |
| 192 | |
| 193 | assert.deepEqual( |
| 194 | spawned.map((command) => ({ command: command.command, args: command.args })), |
| 195 | [ |
| 196 | { command: "cursor", args: ["--classic", "/workspace with spaces"] }, |
| 197 | { command: "cursor", args: ["--classic", "/workspace with spaces/src/index.ts"] }, |
| 198 | { |
| 199 | command: "cursor", |
| 200 | args: ["--classic", "--goto", "/workspace with spaces/src/index.ts:12"], |
| 201 | }, |
| 202 | { |
| 203 | command: "cursor", |
| 204 | args: ["--classic", "--goto", "/workspace with spaces/src/index.ts:12:4"], |
| 205 | }, |
| 206 | ], |
| 207 | ); |
| 208 | }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), |
| 209 | ); |
| 210 | } |
| 211 | |
| 212 | it.effect("launches Cursor in classic IDE mode through the Windows command shim", () => |
| 213 | Effect.gen(function* () { |
| 214 | const fileSystem = yield* FileSystem.FileSystem; |
| 215 | const path = yield* Path.Path; |
| 216 | const binDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-editors-" }); |
| 217 | yield* fileSystem.writeFileString(path.join(binDir, "cursor.CMD"), "@echo off\r\n"); |
| 218 | |
| 219 | let spawned: ChildProcess.StandardCommand | undefined; |
| 220 | yield* Effect.gen(function* () { |
| 221 | const launcher = yield* ExternalLauncher.ExternalLauncher; |
| 222 | yield* launcher.launchEditor({ |
| 223 | editor: "cursor", |
| 224 | cwd: "C:\\workspace with spaces\\src\\index.ts:12:4", |
| 225 | }); |
| 226 | }).pipe( |
| 227 | Effect.provide( |
| 228 | testLayer({ |
| 229 | platform: "win32", |
| 230 | env: { PATH: binDir, PATHEXT: ".COM;.EXE;.BAT;.CMD" }, |
| 231 | resolveExecutable: (command) => |
| 232 | command === "cursor" ? "C:\\Program Files\\Cursor\\bin\\cursor.CMD" : command, |
| 233 | onSpawn: (command) => { |
| 234 | spawned = command; |
| 235 | }, |
| 236 | }), |
| 237 | ), |
| 238 | ); |
| 239 | |
| 240 | assert.ok(spawned); |
| 241 | assert.equal(spawned.command, '^"C:\\Program^ Files\\Cursor\\bin\\cursor.CMD^"'); |
| 242 | assert.deepEqual(spawned.args, [ |
| 243 | '^"--classic^"', |
| 244 | '^"--goto^"', |
| 245 | '^"C:\\workspace^ with^ spaces\\src\\index.ts:12:4^"', |
| 246 | ]); |
| 247 | assert.equal(spawned.options.shell, true); |
| 248 | }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), |
| 249 | ); |
| 250 | |
| 162 | 251 | it.effect.skipIf(windowsHost)("reveals a file in Finder with open -R on macOS", () => |
| 163 | 252 | Effect.gen(function* () { |
| 164 | 253 | const fileSystem = yield* FileSystem.FileSystem; |