Skip to content

Commit

Permalink
chore(bin): make extraESBuildConfig tidier
Browse files Browse the repository at this point in the history
  • Loading branch information
Socketlike committed Feb 25, 2024
1 parent cbd75e8 commit 3955a25
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions bin/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ export const directory = process.cwd();

const dirname = path.dirname(fileURLToPath(import.meta.url));
const packageJson = JSON.parse(readFileSync(path.resolve(dirname, "package.json"), "utf-8"));
let extraESBuildConfig = new Promise<(current: esbuild.BuildOptions) => esbuild.BuildOptions>(
(resolve) => resolve((v) => v),
);

if (existsSync(path.join(directory, "esbuild.extra.mjs"))) {
extraESBuildConfig = new Promise((resolve) => {
import(pathToFileURL(path.join(directory, "esbuild.extra.mjs"))).then((v) => {
resolve(v.default);
});
});
}
const extraESBuildPath = path.join(directory, "esbuild.extra.mjs");
const extraESBuildConfig = new Promise<(config: esbuild.BuildOptions) => esbuild.BuildOptions>(
(resolve) => {
if (existsSync(extraESBuildPath))
resolve(
import(pathToFileURL(extraESBuildPath).href).then((m) => {
resolve(m.default);
}) as Promise<(config: esbuild.BuildOptions) => esbuild.BuildOptions>,
);

resolve((config: esbuild.BuildOptions) => config);
},
);

const updateMessage = `Update available ${chalk.dim("{currentVersion}")}${chalk.reset(
" → ",
Expand Down

0 comments on commit 3955a25

Please sign in to comment.