From f7a4e9626dda98c40221ca0d11bbb642f2e646ed Mon Sep 17 00:00:00 2001 From: greatsquare0 Date: Thu, 8 Aug 2024 14:58:35 -0300 Subject: [PATCH] Hot fixes --- build.mjs => build.mts | 5 +++-- package.json | 2 +- src/handle_config.ts | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) rename build.mjs => build.mts (78%) diff --git a/build.mjs b/build.mts similarity index 78% rename from build.mjs rename to build.mts index 5150447..e048870 100644 --- a/build.mjs +++ b/build.mts @@ -7,8 +7,9 @@ await Bun.build({ sourcemap: 'external', target: 'node', minify: true, - external: ['smol-toml'], - plugins: [dts()], + external: ['extract-zip', 'node-fetch', 'smol-toml'], + plugins: [dts()], }) + copyFileSync('./config_template.toml', './dist/config_template.toml') \ No newline at end of file diff --git a/package.json b/package.json index df79ff2..ed572dc 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "description": "", "scripts": { - "build": "bun run build.mjs", + "build": "bun run build.mts", "prepublishOnly": "bun run build" }, "files": [ diff --git a/src/handle_config.ts b/src/handle_config.ts index 8ed2894..73168b6 100644 --- a/src/handle_config.ts +++ b/src/handle_config.ts @@ -1,5 +1,7 @@ import { existsSync, copyFileSync, readFileSync } from "node:fs"; import { parse } from "smol-toml"; +import { fileURLToPath } from "url"; +import { dirname } from "path"; const projectRoot = process.cwd() @@ -16,6 +18,9 @@ const handleConfig = () => { } +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + const readConfigFile = () => { const configRaw = readFileSync(`${projectRoot}/${configFileName}`, 'utf-8') try { @@ -29,7 +34,7 @@ const readConfigFile = () => { const createConfigFile = () => { try { - copyFileSync(`${import.meta.dir}/config_template.toml`, `${projectRoot}/${configFileName}`) + copyFileSync(`${__dirname}/config_template.toml`, `${projectRoot}/${configFileName}`) return } catch (error) { throw new Error(`Failed to create the TOML: ${error}`)