From 2c904542440eb0898801ff8944ecd8ce24b36bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Krzeslak?= Date: Thu, 24 Jul 2025 10:42:36 +0200 Subject: [PATCH] test: extract ExecFileFn type to separate file to make it reusable --- src/converters/assimp.ts | 9 ++------- src/converters/types.ts | 5 +++++ 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 src/converters/types.ts diff --git a/src/converters/assimp.ts b/src/converters/assimp.ts index 95aa2b9..869f28e 100644 --- a/src/converters/assimp.ts +++ b/src/converters/assimp.ts @@ -1,10 +1,5 @@ import { execFile as execFileOriginal } from "node:child_process"; - -export type ExecFileFn = ( - cmd: string, - args: string[], - callback: (err: Error | null, stdout: string, stderr: string) => void, -) => void; +import { ExecFileFn } from "./types.ts"; export const properties = { from: { @@ -123,7 +118,7 @@ export async function convert( convertTo: string, targetPath: string, options?: unknown, - execFile: ExecFileFn = execFileOriginal, + execFile: ExecFileFn = execFileOriginal, // to make it mockable ): Promise { return new Promise((resolve, reject) => { execFile("assimp", ["export", filePath, targetPath], (error, stdout, stderr) => { diff --git a/src/converters/types.ts b/src/converters/types.ts new file mode 100644 index 0000000..a80a873 --- /dev/null +++ b/src/converters/types.ts @@ -0,0 +1,5 @@ +export type ExecFileFn = ( + cmd: string, + args: string[], + callback: (err: Error | null, stdout: string, stderr: string) => void, +) => void;