Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Sep 22, 2023
1 parent 66c9fbd commit 303ca19
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 26 deletions.
6 changes: 2 additions & 4 deletions Source/Execution/TypeScriptESBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import { Command } from "commander";
try {
new Command()
.name("TypeScriptESBuild")
.version((await _JSON("../../package.json", import.meta.url))?.version)
.version(process.env["VERSION_PACKAGE"] ?? "0.0.1")
.description("Builds files")
.argument("<Files...>", "Files to build")
.option("-es, --ESBuild <File>", "esbuild configuration file")
.option("-ts, --TypeScript <File>", "TypeScript configuration file")
.action(Build)
.parse();
} catch (_Error) {
console.log(_Error);
}
} catch (_Error) {}
3 changes: 1 addition & 2 deletions Source/Fn/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { pathToFileURL as URL } from "url";
export default async (Path: string) => {
if (Path.split(".").pop() === "ts") {
const { options } = TypeScript.convertCompilerOptionsFromJson(
(await _JSON("../Notation/TypeScript.json", import.meta.url))
?.compilerOptions,
(await _JSON("../Notation/TypeScript.json"))?.compilerOptions,
"."
);

Expand Down
13 changes: 2 additions & 11 deletions Source/Fn/JSON.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { readFile as _File } from "fs/promises";
import { dirname as Dir } from "path";
import { fileURLToPath as Path } from "url";

/**
* The function `JSON` is a TypeScript function that reads a JSON file and returns its parsed content.
Expand All @@ -10,12 +8,5 @@ import { fileURLToPath as Path } from "url";
* from which the JSON file will be loaded. It is set to `import.meta.url` by default, which refers to
* the URL of the current module. However, if a different source URL or file path is provided,
*/
export default async (File: string, From: string = import.meta.url) =>
JSON.parse(
(
await _File(
`${Dir(Path(From ?? import.meta.url))}/${File}`,
"utf-8"
)
).toString()
);
export default async (File: string) =>
JSON.parse((await _File(`${File}`, "utf-8")).toString());
11 changes: 7 additions & 4 deletions Source/Object/Option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { PluginBuild as Build, BuildOptions as Option } from "esbuild";
import { copy as Copy } from "esbuild-plugin-copy";
import { rm as Remove } from "fs/promises";

import _JSON from "../Fn/JSON.js";

const Out = "Target";

export default {
Expand All @@ -17,14 +19,11 @@ export default {
name: "Target",
setup(Build: Build) {
Build.onStart(async () => {
console.log(Out)
try {
await Remove(Out, {
recursive: true,
});
} catch (_Error) {
console.log(_Error);
}
} catch (_Error) {}
});
},
},
Expand All @@ -38,4 +37,8 @@ export default {
],
}),
],
define: {
"process.env.VERSION_PACKAGE": `'${(await _JSON("package.json"))
?.version}'`,
},
} satisfies Option as Option;
2 changes: 1 addition & 1 deletion Target/Execution/TypeScriptESBuild.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Target/Fn/File.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Target/Fn/JSON.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* from which the JSON file will be loaded. It is set to `import.meta.url` by default, which refers to
* the URL of the current module. However, if a different source URL or file path is provided,
*/
declare const _default: (File: string, From?: string) => Promise<any>;
declare const _default: (File: string) => Promise<any>;
export default _default;
2 changes: 1 addition & 1 deletion Target/Fn/JSON.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import{readFile as a}from"fs/promises";import{dirname as i}from"path";import{fileURLToPath as m}from"url";var s=async(r,t=import.meta.url)=>JSON.parse((await a(`${i(m(t??import.meta.url))}/${r}`,"utf-8")).toString());export{s as default};
import{readFile as a}from"fs/promises";var e=async t=>JSON.parse((await a(`${t}`,"utf-8")).toString());export{e as default};
2 changes: 1 addition & 1 deletion Target/Object/Option.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 303ca19

Please sign in to comment.