Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
chore: use dynamic deno executable path
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Sep 15, 2024
1 parent ff7c403 commit 75e39fc
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/backend/cli/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { migrateModeSchema } from "./../util.ts";
import { ensurePostgresRunning, getDefaultDatabaseUrl } from "../../toolchain/postgres/mod.ts";
import { InternalState } from "../../toolchain/internal_api/state.ts";
import { createAndStartProjectInternalApiRouter } from "../../toolchain/internal_api/mod.ts";
import { denoExecutablePath } from "../../toolchain/utils/deno.ts";

export const optsSchema = z.object({
build: z.boolean().default(true),
Expand Down Expand Up @@ -75,7 +76,7 @@ export async function execute(opts: Opts) {

// Run entrypoint
const entrypointPath = projectCachePath(project, ENTRYPOINT_PATH);
const cmd = await new Deno.Command("deno", {
const cmd = await new Deno.Command(denoExecutablePath(), {
args: [
"run",
...args,
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/cli/commands/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from "zod";
import { globalOptsSchema, initProject } from "../common.ts";
import { listSourceFiles } from "../../toolchain/project/mod.ts";
import { UserError } from "../../toolchain/error/mod.ts";
import { denoExecutablePath } from "../../toolchain/utils/deno.ts";

export const optsSchema = globalOptsSchema.extend({
check: z.boolean().nullable(),
Expand All @@ -14,7 +15,7 @@ export async function execute(opts: Opts) {

const sourceFiles = await listSourceFiles(project, { localOnly: true });

const cmd = await new Deno.Command("deno", {
const cmd = await new Deno.Command(denoExecutablePath(), {
args: [
"fmt",
...opts.check ? ["--check"] : [],
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/cli/commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from "zod";
import { globalOptsSchema, initProject } from "../common.ts";
import { listSourceFiles } from "../../toolchain/project/mod.ts";
import { UserError } from "../../toolchain/error/mod.ts";
import { denoExecutablePath } from "../../toolchain/utils/deno.ts";

export const optsSchema = z.object({
// Add any command-specific options here
Expand All @@ -14,7 +15,7 @@ export async function execute(opts: Opts) {

const sourceFiles = await listSourceFiles(project, { localOnly: true });

const cmd = await new Deno.Command("deno", {
const cmd = await new Deno.Command(denoExecutablePath(), {
args: [
"lint",
...sourceFiles,
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { UserError } from "../../toolchain/error/mod.ts";
import { info } from "../../toolchain/term/status.ts";
import { migrateModeSchema } from "./../util.ts";
import { ensurePostgresRunning, getDefaultDatabaseUrl } from "../../toolchain/postgres/mod.ts";
import { denoExecutablePath } from "../../toolchain/utils/deno.ts";

export const optsSchema = z.object({
build: z.boolean().default(true),
Expand Down Expand Up @@ -96,7 +97,7 @@ export async function execute(opts: Opts) {

// Run tests
info("Testing", testingModules.join(", "));
const cmd = await new Deno.Command("deno", {
const cmd = await new Deno.Command(denoExecutablePath(), {
args: [
"test",
...args,
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/toolchain/build/gen/code_builder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dedent from "dedent";
import { dirname, format as formatPath, isAbsolute, parse as parsePath, relative, resolve } from "@std/path";
import { autoGenHeader } from "../misc.ts";
import { denoExecutablePath } from "../../utils/deno.ts";

export enum Lang {
Typescript,
Expand Down Expand Up @@ -166,7 +167,7 @@ async function mkdirFor(path: string) {
}
async function writeFmt(path: string, source: string) {
await Deno.writeTextFile(path, source);
const formatResult = await new Deno.Command("deno", {
const formatResult = await new Deno.Command(denoExecutablePath(), {
args: ["fmt", path],
}).output();
if (!formatResult.success) {
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/toolchain/build/plan/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { migratePush } from "../../migrate/push.ts";
import { migrateApply } from "../../migrate/apply.ts";
import { migrateGenerate } from "../../migrate/generate.ts";
import { generateSdk } from "../../sdk/generate.ts";
import { denoExecutablePath } from "../../utils/deno.ts";

export async function planProjectBuild(
buildState: BuildState,
Expand Down Expand Up @@ -273,7 +274,7 @@ export async function planProjectBuild(
name: "Check",
description: "entrypoint.ts",
async build() {
const checkOutput = await new Deno.Command("deno", {
const checkOutput = await new Deno.Command(denoExecutablePath(), {
args: ["check", "--quiet", projectCachePath(project, "entrypoint.ts")],
signal,
}).output();
Expand Down
5 changes: 3 additions & 2 deletions packages/backend/toolchain/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import dedent from "dedent";
import { compileDbSchemaHelper } from "./build/gen/db_schema.ts";
import { DRIZZLE_KIT_PACKAGE, DRIZZLE_ORM_PACKAGE, PG_PACKAGE } from "./drizzle_consts.ts";
import { getDefaultDatabaseUrl } from "./postgres/mod.ts";
import { denoExecutablePath } from "./utils/deno.ts";

export interface RunCommandOpts {
args: string[];
Expand Down Expand Up @@ -86,7 +87,7 @@ export async function runDrizzleCommand(project: Project, module: Module, opts:
// Install dependencies
//
// This uses node_modules since drizzle-kit depends on being able to import `drizzle-orm`.
const denoCache = await new Deno.Command("deno", {
const denoCache = await new Deno.Command(denoExecutablePath(), {
args: ["cache", "--node-modules-dir", DRIZZLE_ORM_PACKAGE, DRIZZLE_KIT_PACKAGE, PG_PACKAGE],
cwd: tempDir,
signal,
Expand All @@ -96,7 +97,7 @@ export async function runDrizzleCommand(project: Project, module: Module, opts:
}

// Run drizzle-kit
const drizzleOutput = await new Deno.Command("deno", {
const drizzleOutput = await new Deno.Command(denoExecutablePath(), {
// TODO: Specify drizzle version
args: ["run", "-A", "--node-modules-dir", DRIZZLE_KIT_PACKAGE, "--config", "database.config.json", ...opts.args],
cwd: tempDir,
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/toolchain/utils/deno.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function denoExecutablePath(): string {
return Deno.execPath();
}

0 comments on commit 75e39fc

Please sign in to comment.