Skip to content

Commit c8ed5f1

Browse files
authored
fix: module path for compiled (#116)
1 parent 970d2f6 commit c8ed5f1

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/modules/updater.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
getModulePath,
33
getOS,
44
getOSName,
5-
getPath,
65
getTemporalUpdateFilePathname,
76
} from "../utils/main.ts";
87
import { OS } from "../enums/main.ts";
@@ -106,7 +105,7 @@ export const update = async ({
106105

107106
log(`[${label}] Update files downloaded!`);
108107
const dirPath = getModulePath("");
109-
const updateFilePath = getModulePath(getTemporalUpdateFilePathname());
108+
const updateFilePath = getTemporalUpdateFilePathname();
110109
const updateFile = path.join(dirPath, `update_${osAsset.name}`);
111110
const updatedFile = path.join(dirPath, osAsset.name);
112111

src/utils/path.utils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@ import * as path from "@std/path";
33
export const getExecPath = (): string => Deno.execPath();
44
export const getPath = (): string => path.dirname(getExecPath());
55

6-
export const getModulePath = (filePath: string = ""): string =>
7-
path.join(path.dirname(path.fromFileUrl(Deno.mainModule)), filePath);
6+
export const getModulePath = (filePath: string = ""): string => {
7+
// If running uncompiled (`deno run main.ts`), use Deno.mainModule
8+
const root = Deno.mainModule.startsWith("file:")
9+
? path.dirname(path.fromFileUrl(Deno.mainModule))
10+
: path.dirname(getExecPath());
11+
12+
return path.join(root, filePath);
13+
};

0 commit comments

Comments
 (0)