Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Sep 26, 2023
1 parent 087c4ad commit 9da18a7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Source/Function/File.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
/**
* The function takes a file path as input, checks if it is a TypeScript file, converts the TypeScript
* code to JavaScript, and then imports and returns the default export of the JavaScript file.
*
* @module File
*
* @param {string} Path - The `Path` parameter is a string that represents the file path of the file
* you want to process.
*
* @returns the default export of the module that is imported using the provided `Path`.
*/
export default async (Path: string) => {
export default (async (...[Path]: Parameters<Type>) => {
if (Path.split(".").pop() === "ts") {
const { options } = (
await import("typescript")
Expand Down Expand Up @@ -51,4 +44,6 @@ export default async (Path: string) => {
.replace(".ts", ".js")
)
).default;
};
}) satisfies Type as Type;

import type Type from "../Interface/File.js";
22 changes: 22 additions & 0 deletions Source/Interface/File.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @module File
*
*/
export default interface Type {
/**
* This function asynchronously processes a file located at the given path. If the file is a TypeScript
* (.ts) file, it performs the following steps:
* 1. Converts TypeScript code to JavaScript.
* 2. Creates a JavaScript module and emits it.
* 3. Writes the transpiled JavaScript code to a new file with a .js extension.
*
* Finally, it imports and returns the default export of the processed JavaScript module.
*
* @param {string} Path - The 'Path' parameter is a string that represents the file path of the file
* you want to process.
*
* @returns {Promise<any>} A promise that resolves with the default export of the module imported using the provided 'Path'.
*/
// rome-ignore lint/suspicious/noExplicitAny: <explanation>
(Path: string): Promise<any>;
}

0 comments on commit 9da18a7

Please sign in to comment.