test: extract ExecFileFn type to separate file to make it reusable
This commit is contained in:
parent
2db99edeaf
commit
2c90454244
2 changed files with 7 additions and 7 deletions
|
|
@ -1,10 +1,5 @@
|
||||||
import { execFile as execFileOriginal } from "node:child_process";
|
import { execFile as execFileOriginal } from "node:child_process";
|
||||||
|
import { ExecFileFn } from "./types.ts";
|
||||||
export type ExecFileFn = (
|
|
||||||
cmd: string,
|
|
||||||
args: string[],
|
|
||||||
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
export const properties = {
|
export const properties = {
|
||||||
from: {
|
from: {
|
||||||
|
|
@ -123,7 +118,7 @@ export async function convert(
|
||||||
convertTo: string,
|
convertTo: string,
|
||||||
targetPath: string,
|
targetPath: string,
|
||||||
options?: unknown,
|
options?: unknown,
|
||||||
execFile: ExecFileFn = execFileOriginal,
|
execFile: ExecFileFn = execFileOriginal, // to make it mockable
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
execFile("assimp", ["export", filePath, targetPath], (error, stdout, stderr) => {
|
execFile("assimp", ["export", filePath, targetPath], (error, stdout, stderr) => {
|
||||||
|
|
|
||||||
5
src/converters/types.ts
Normal file
5
src/converters/types.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export type ExecFileFn = (
|
||||||
|
cmd: string,
|
||||||
|
args: string[],
|
||||||
|
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
||||||
|
) => void;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue