Skip to content

Commit

Permalink
fix template resolution for wrangler
Browse files Browse the repository at this point in the history
  • Loading branch information
james-elicx committed Jul 3, 2023
1 parent b98a223 commit c39173b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-suits-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'cf-bindings-proxy': minor
---

Initial support for running a proxy for bindings with D1/KV/R2.
10 changes: 8 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { spawn } from 'node:child_process';
import { resolve } from 'node:path';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

// eslint-disable-next-line @typescript-eslint/naming-convention
const __filename = fileURLToPath(import.meta.url);
// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = dirname(__filename);

/**
* Spawns wrangler dev mode with the binding proxy template.
Expand All @@ -12,7 +18,7 @@ export const spawnDevMode = async () => {

const wrangler = spawn(
executor,
['wrangler', 'pages', 'dev', resolve('./template'), '--port=8799', ...passThroughArgs],
['wrangler', 'pages', 'dev', resolve(__dirname, 'template'), '--port=8799', ...passThroughArgs],
{ stdio: 'inherit' },
);

Expand Down
4 changes: 2 additions & 2 deletions src/cli/template.ts → src/cli/template/_worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BindingRequest, BindingResponse, PropertyCall } from '../proxy';
import { transformData } from '../transform';
import type { BindingRequest, BindingResponse, PropertyCall } from '../../proxy';
import { transformData } from '../../transform';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Env = { [key: string]: any };
Expand Down

0 comments on commit c39173b

Please sign in to comment.