Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Make Shortest compatible with Windows #256

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/shortest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dist/cli"
],
"scripts": {
"build": "rm -rf dist && pnpm build:types && pnpm build:js && pnpm build:cli",
"build": "rimraf dist && pnpm build:types && pnpm build:js && pnpm build:cli",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm -rf for Node in a cross-platform implementation

"prepare": "pnpm build",
"prepublishOnly": "pnpm build",
"postinstall": "node -e \"if (process.platform !== 'win32') { try { require('child_process').execSync('chmod +x dist/cli/bin.js') } catch (_) {} }\"",
Expand All @@ -47,20 +47,21 @@
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.11.24",
"tsx": "^4.7.1",
"typescript": "~5.6.2",
"package-manager-detector": "0.2.8",
"tsup": "8.3.5"
"rimraf": "^6.0.1",
"tsup": "8.3.5",
"tsx": "^4.7.1",
"typescript": "~5.6.2"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@anthropic-ai/sdk": "0.32.0",
"mailosaur": "^8.7.0",
"dotenv": "^16.4.5",
"esbuild": "^0.20.1",
"expect": "^29.7.0",
"mailosaur": "^8.7.0",
"playwright": "^1.48.2"
},
"author": "Antiwork",
Expand Down
4 changes: 2 additions & 2 deletions packages/shortest/src/core/compiler/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mkdirSync, existsSync, writeFileSync } from "fs";
import { tmpdir } from "os";
import { join, resolve } from "path";
import { join, resolve, basename } from "path";
import { build, BuildOptions } from "esbuild";

export class TestCompiler {
Expand Down Expand Up @@ -46,7 +46,7 @@ export class TestCompiler {
}

async compileFile(filePath: string): Promise<string> {
const fileName = filePath.split("/").pop()!.replace(".ts", ".mjs");
const fileName = basename(filePath).replace(".ts", ".mjs");
const outputPath = join(this.cacheDir, fileName);

const packageJson = {
Expand Down
3 changes: 2 additions & 1 deletion packages/shortest/src/core/runner/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathToFileURL } from "url";
import Anthropic from "@anthropic-ai/sdk";
import { glob } from "glob";
import pc from "picocolors";
Expand Down Expand Up @@ -341,7 +342,7 @@ export class TestRunner {
const filePathWithoutCwd = file.replace(this.cwd + "/", "");
this.logger.startFile(filePathWithoutCwd);
const compiledPath = await this.compiler.compileFile(file);
await import(compiledPath);
await import(pathToFileURL(compiledPath).href);

const context = await this.browserManager.launch();
const testContext = await this.createTestContext(context);
Expand Down
Loading
Loading