diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index a8482ba..ade0419 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -7,98 +7,98 @@ import { timeout, cssFile, textFile, fontPath, fontDir, fontName, unlink, rmdir // https://github.com/piscinajs/piscina/issues/83 describe("FontRange Offline Feature", () => { const saveDir = join(fontDir, "offline"); - beforeAll(async () => { - return await fontRange(fontPath, cssFile, { - saveDir, - nameFormat: "{NAME}.subset.{INDEX}{EXT}" - }); - }, timeout); afterAll(() => { rmdir(saveDir); }); it("Font Created Check", async () => { + await fontRange(fontPath, cssFile, { + saveDir, + nameFormat: "{NAME}.subset.{INDEX}{EXT}" + }); + const parsed = await parseCSS(fontDir, cssFile); const parsedL = parsed.length; for (let counts = 0; counts < parsedL; counts++) { const fontFile = join(saveDir, fontName + ".subset." + counts + ".woff2"); expect(existsSync(fontFile)).toBe(true); } - }); + }, timeout); }); describe("FontRange Options with srcIndex", () => { const saveDir = join(fontDir, "srcIndex"); - beforeAll(async () => { - return await fontRange(fontPath, cssFile, { + afterAll(() => { + rmdir(saveDir); + }); + + it("Font Created Check", async () => { + await fontRange(fontPath, cssFile, { saveDir, nameFormat: "{NAME}.subset.{INDEX}{EXT}", logFormat: "{ORIGIN} to {OUTPUT}", fromCSS: "srcIndex" }); - }, timeout); - afterAll(() => { - rmdir(saveDir); - }); - it("Font Created Check", async () => { // Partial file checks const fontFile1 = join(saveDir, fontName + ".subset." + 119 + ".woff2"); const fontFile2 = join(saveDir, fontName + ".subset." + 120 + ".woff2"); expect(existsSync(fontFile1)).toBe(false); expect(existsSync(fontFile2)).toBe(true); - }); + }, timeout); }); describe("FontRange srcName Option", () => { const saveDir = join(fontDir, "srcName"); - beforeAll(async () => { - return await fontRange(fontPath, cssFile, { - saveDir, - fromCSS: "srcName" - }); - }, timeout); afterAll(() => { rmdir(saveDir); }); it("Font Created Check", async () => { + await fontRange(fontPath, cssFile, { + saveDir, + fromCSS: "srcName" + }); + // Partial file checks const fontFile1 = join(saveDir, "PbykFmXiEBPT4ITbgNA5Cgm20xz64px_1hVWr0wuPNGmlQNMEfD4.0.woff2" ); const fontFile2 = join(saveDir, "PbykFmXiEBPT4ITbgNA5Cgm20xz64px_1hVWr0wuPNGmlQNMEfD4.120.woff2"); expect(existsSync(fontFile1)).toBe(true); expect(existsSync(fontFile2)).toBe(true); - }); + }, timeout); }); // online describe("FontRange Online Feature", () => { const saveDir = join(fontDir, "online"); - beforeAll(async () => { - return await fontRange(fontPath, targets.korean, saveDir); - }, timeout); afterAll(() => { rmdir(saveDir); }); - it("Check CSS Download", () => { + it("Font Created Check", async () => { + await fontRange(fontPath, targets.korean, saveDir); + + // CSS Downlad check const cssPath = join(saveDir, "Noto Sans KR.css"); expect(existsSync(cssPath)).toBe(true); - }); - it("Font Created Check", async () => { + // Create check const parsed = await parseCSS(saveDir, cssFile); const parsedL = parsed.length; for (let counts = 0; counts < parsedL; counts++) { const fontFile = join(saveDir, fontName + "_" + counts + ".woff2"); expect(existsSync(fontFile)).toBe(true); } - }); + }, timeout); }); describe("FontSubset Format & Glyph Feature", () => { const saveDir = join(fontDir, "format"); - beforeAll(async () => { + afterAll(() => { + rmdir(saveDir); + }); + + it("Font Created Check", async () => { const font1 = await fontSubset(fontPath, { saveDir, text: "abcd", @@ -124,13 +124,8 @@ describe("FontSubset Format & Glyph Feature", () => { text: "abcd", format: "woff-zopfli" }); - return Promise.all([font1, font2, font3, font4, font5]) - }, timeout); - afterAll(() => { - rmdir(saveDir); - }); + await Promise.all([font1, font2, font3, font4, font5]) - it("Font Created Check", async () => { const fontFile1 = join(saveDir, fontName + "_" + ".otf" ); const fontFile2 = join(saveDir, fontName + "_" + ".ttf" ); const fontFile3 = join(saveDir, fontName + "_" + ".woff2"); @@ -141,36 +136,33 @@ describe("FontSubset Format & Glyph Feature", () => { expect(existsSync(fontFile3)).toBe(true); expect(existsSync(fontFile4)).toBe(true); expect(existsSync(fontFile5)).toBe(true); - }); + }, timeout); }); describe("FontSubset Glyphs File Feature", () => { - beforeAll(async () => { - return await fontSubset(fontPath, { + it("Font Created Check", async () => { + await fontSubset(fontPath, { textFile, nameFormat: "{NAME}.glyphFile{INDEX}{EXT}" }); - }, timeout); - it("Font Created Check", async () => { const fontFile = join(fontDir, fontName + ".glyphFile" + ".woff2"); expect(existsSync(fontFile)).toBe(true); unlink(fontFile); - }); + }, timeout); }); describe("FontPipe Feature", () => { - beforeAll(async () => { + it("Font Created Check", async () => { + console.log = jest.fn(); const pipe = [ { fontPath }, { fontPath, option: { textFile, nameFormat: "{NAME}.pipe.{INDEX}{EXT}" } }, { fontPath, option: { cssFile, nameFormat: "{NAME}.pipe.{INDEX}{EXT}" } } ]; - return await fontPipe(pipe); - }, timeout * 3); + await fontPipe(pipe); - it("Font Created Check", async () => { const fontFile1 = join(fontDir, fontName + "_" + ".woff2"); const fontFile2 = join(fontDir, fontName + ".pipe." + ".woff2"); @@ -186,38 +178,46 @@ describe("FontPipe Feature", () => { expect(existsSync(eachFontPath)).toBe(true); unlink(eachFontPath); } - }); + expect(console.log).not.toHaveBeenCalled(); + }, timeout * 2); }); describe("FontPipe Shard with Args", () => { const saveDir = join(fontDir, "shardArgs"); - beforeAll(async () => { + afterAll(() => { + rmdir(saveDir); + }); + + it("Font Created Check", async () => { + console.log = jest.fn(); const pipe = [ { fontPath, option: { saveDir } }, { fontPath, option: { saveDir, textFile, nameFormat: "{NAME}.pipe.{INDEX}{EXT}" } }, { fontPath, option: { saveDir, cssFile, nameFormat: "{NAME}.pipe.{INDEX}{EXT}" } } ]; - return await fontPipe(pipe, "1/2"); - }, timeout); - afterAll(() => { - rmdir(saveDir); - }); + await fontPipe(pipe, "1/2"); - it("Font Created Check", async () => { const fontFile1 = join(saveDir, fontName + "_" + ".woff2"); const fontFile2 = join(saveDir, fontName + ".pipe." + ".woff2"); expect(existsSync(fontFile1)).toBe(true); expect(existsSync(fontFile2)).toBe(true); - }); + expect(console.log).toHaveBeenCalledWith("== 1/2 =========="); + }, timeout); }); describe("FontPipe Shard with Env", () => { const saveDir = join(fontDir, "shardEnv"); const OLD_ENV = process.env; - beforeAll(async () => { + afterAll(() => { + process.env = OLD_ENV; + rmdir(saveDir); + }); + + it("Font Created Check", async () => { + console.log = jest.fn(); process.env = { - ...OLD_ENV, + ...OLD_ENV, SHARD: "2/2" }; const pipe = [ @@ -225,21 +225,16 @@ describe("FontPipe Shard with Env", () => { { fontPath, option: { saveDir, textFile, nameFormat: "{NAME}.pipe.{INDEX}{EXT}" } }, { fontPath, option: { saveDir, cssFile, nameFormat: "{NAME}.pipe.{INDEX}{EXT}" } } ]; - return await fontPipe(pipe); - }, timeout); - afterAll(() => { - process.env = OLD_ENV; - rmdir(saveDir); - }); + await fontPipe(pipe); - it("Font Created Check", async () => { const parsed = await parseCSS(fontDir, cssFile); const parsedL = parsed.length; for (let counts = 0; counts < parsedL; counts++) { const eachFontPath = join(saveDir, fontName + ".pipe." + counts + ".woff2"); expect(existsSync(eachFontPath)).toBe(true); } - }); + expect(console.log).toHaveBeenCalledWith("== 2/2 =========="); + }, timeout); }); describe("FontPipe Shard Error", () => { @@ -257,12 +252,16 @@ describe("FontPipe Shard Error", () => { }); it("Number parsing", async() => { + console.log = jest.fn(); await expect(run("a120")).rejects.toThrow(" must be a positive number"); await expect(run("a/20")).rejects.toThrow(" must be a positive number"); await expect(run("0/20")).rejects.toThrow(" must be a positive number"); await expect(run("1/a2")).rejects.toThrow(" must be a positive number"); + expect(console.log).not.toHaveBeenCalled(); }); it("Index size", async() => { + console.log = jest.fn(); await expect(run("22/2")).rejects.toThrow(" must be less then "); + expect(console.log).not.toHaveBeenCalled(); }); }); diff --git a/__tests__/preset.test.ts b/__tests__/preset.test.ts index 1cf1b1b..dfa1d1b 100644 --- a/__tests__/preset.test.ts +++ b/__tests__/preset.test.ts @@ -27,18 +27,37 @@ describe("Preset Check", () => { }); describe("Pyftsubset Check", () => { - const fontFile = join(fontDir, fontName + ".preset.woff2"); + it("Subset check with no Log", async () => { + const fontFile = join(fontDir, fontName + ".preset.woff2"); + console.log = jest.fn(); - beforeAll(() => { - return subset([ + subset({options: [ fontPath, "--output-file=" + fontFile, "--text-file=" + textFile, ...defaultArgs - ]); + ]}); + + expect(console.log).not.toHaveBeenCalled(); + expect(existsSync(fontFile)).toBe(true); + unlink(fontFile); }); - it("Subset check", async () => { + it("Subset check with log", async () => { + const fontFile = join(fontDir, fontName + ".log.woff2"); + console.log = jest.fn(); + + subset({ + options: [ + fontPath, + "--output-file=" + fontFile, + "--text-file=" + textFile, + ...defaultArgs + ], + log: "== pyftsubset run ==" + }); + + expect(console.log).toHaveBeenCalledWith("== pyftsubset run =="); expect(existsSync(fontFile)).toBe(true); unlink(fontFile); }); diff --git a/build/main.js b/build/main.js index a8b3455..3fef660 100644 --- a/build/main.js +++ b/build/main.js @@ -187,7 +187,25 @@ function formatOption(format) { (format === "woff-zopfli") ? "--with-zopfli" : "" ]; } -function getOptionInfos(fontPath = "", fontOption) { +function fileNameInit(nameFormat, fontName, fontExt) { + return nameFormat + .replace("{NAME}", fontName) + .replace("{EXT}", fontExt); +} +function getFileName(initName, index) { + return initName + .replace("{INDEX}", (typeof index === "number") + ? index.toString() + : (typeof index === "string") + ? index + : ""); +} +function getConsoleLog(logFormat, origin, output) { + return logFormat + .replace("{ORIGIN}", origin) + .replace("{OUTPUT}", output); +} +function getOptionInfos(fontPath = "", fontOption, indexIndicate = "") { const options = Object.assign({ fromCSS: "default" }, getDefaultOptions(), typeof (fontOption) === "string" ? { saveDir: fontOption } : fontOption); @@ -200,6 +218,9 @@ function getOptionInfos(fontPath = "", fontOption) { const dirPath = Object.prototype.hasOwnProperty.call(options, "saveDir") ? options["saveDir"] : fontDir; const nameFormat = options.nameFormat; const logFormat = options.logFormat; + const initName = fileNameInit(nameFormat, fontName, fontExt); + const output = getFileName(initName, indexIndicate); + const logMsg = getConsoleLog(logFormat, fontBase, output); const convertOption = formatOption(format); const defaultOption = options.defaultArgs; const etcOption = options.etcArgs; @@ -210,64 +231,14 @@ function getOptionInfos(fontPath = "", fontOption) { ].filter(option => option !== ""); const worker = Worker.getInstance(); return { - fontBase, - fontName, - fontExt, dirPath, - nameFormat, - logFormat, + initName, + logMsg, baseOption, worker, fromCSS: options.fromCSS }; } -function fileNameInit(nameFormat, fontName, fontExt) { - return nameFormat - .replace("{NAME}", fontName) - .replace("{EXT}", fontExt); -} -function getFileName(initName, index) { - return initName - .replace("{INDEX}", (typeof index === "number") - ? index.toString() - : (typeof index === "string") - ? index - : ""); -} -function getConsoleLog(logFormat, origin, output) { - return logFormat - .replace("{ORIGIN}", origin) - .replace("{OUTPUT}", output); -} -function getSaveOption(dirPath, initName, index) { - const fileName = getFileName(initName, index); - return ("--output-file=" + (0, path_1.join)(dirPath, fileName)); -} -function getSubsetOption(fontSubsetOption) { - if (typeof fontSubsetOption !== "undefined" && - typeof fontSubsetOption !== "string") { - if ("textFile" in fontSubsetOption) { - return ("--text-file=" + fontSubsetOption.textFile); - } - if ("text" in fontSubsetOption) { - return ("--text=" + fontSubsetOption.text); - } - } - return "--glyphs=*"; -} -function initWithLog(dirPath, fontBase, fontName, fontExt, nameFormat, logFormat, index) { - return tslib_1.__awaiter(this, void 0, void 0, function* () { - const initName = fileNameInit(nameFormat, fontName, fontExt); - if (!(0, fs_1.existsSync)(dirPath)) - yield (0, promises_1.mkdir)(dirPath); - if (logFormat !== "") { - const output = getFileName(initName, index); - const log = getConsoleLog(logFormat, fontBase, output); - console.log(log); - } - return initName; - }); -} function getSrcInfo(src) { const first = src.split(",").find((str) => { return str.indexOf("url(") === 0; @@ -289,10 +260,25 @@ function getSrcInfo(src) { index: parseInt(parsedURL.name.split(".").pop()) }; } +function getSaveOption(dirPath, initName, index) { + const fileName = getFileName(initName, index); + return ("--output-file=" + (0, path_1.join)(dirPath, fileName)); +} +function getSubsetOption(fontSubsetOption) { + if (typeof fontSubsetOption !== "undefined" && + typeof fontSubsetOption !== "string") { + if ("textFile" in fontSubsetOption) { + return ("--text-file=" + fontSubsetOption.textFile); + } + if ("text" in fontSubsetOption) { + return ("--text=" + fontSubsetOption.text); + } + } + return "--glyphs=*"; +} function fontRange(fontPath = "", url = exports.targets.korean, fontRangeOption) { return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { fontBase, fontName, fontExt, dirPath, nameFormat, logFormat, baseOption, worker, fromCSS } = getOptionInfos(fontPath, fontRangeOption); - const initName = yield initWithLog(dirPath, fontBase, fontName, fontExt, nameFormat, logFormat, "n"); + const { dirPath, initName, logMsg, baseOption, worker, fromCSS } = getOptionInfos(fontPath, fontRangeOption, "n"); const ranges = yield parseCSS(dirPath, url); const result = ranges.map(({ src, unicodes }, i) => tslib_1.__awaiter(this, void 0, void 0, function* () { const srcInfo = getSrcInfo(src); @@ -304,7 +290,8 @@ function fontRange(fontPath = "", url = exports.targets.korean, fontRangeOption) const unicodeRanges = unicodes.split(", ").join(","); const unicodeOption = "--unicodes=" + unicodeRanges; const options = [fontPath, saveOption, unicodeOption, ...baseOption]; - const result = yield worker.run(options); + const logInfo = (i === 0) ? logMsg : ""; + const result = yield worker.run({ options, log: logInfo }); return result; })); return yield Promise.all(result); @@ -313,12 +300,13 @@ function fontRange(fontPath = "", url = exports.targets.korean, fontRangeOption) exports.fontRange = fontRange; function fontSubset(fontPath = "", fontSubsetOption) { return tslib_1.__awaiter(this, void 0, void 0, function* () { - const { fontBase, fontName, fontExt, dirPath, nameFormat, logFormat, baseOption, worker } = getOptionInfos(fontPath, fontSubsetOption); - const initName = yield initWithLog(dirPath, fontBase, fontName, fontExt, nameFormat, logFormat); + const { dirPath, initName, logMsg, baseOption, worker } = getOptionInfos(fontPath, fontSubsetOption); + if (!(0, fs_1.existsSync)(dirPath)) + yield (0, promises_1.mkdir)(dirPath); const subsetOption = getSubsetOption(fontSubsetOption); const saveOption = getSaveOption(dirPath, initName); const options = [fontPath, saveOption, subsetOption, ...baseOption]; - const result = yield worker.run(options); + const result = yield worker.run({ options, log: logMsg }); return result; }); } diff --git a/build/worker.d.ts b/build/worker.d.ts index c55ccdc..221b904 100644 --- a/build/worker.d.ts +++ b/build/worker.d.ts @@ -1 +1,5 @@ -export default function subset(options: string[]): import("@esm2cjs/execa").ExecaSyncReturnValue; +export interface SubsetI { + options: string[]; + log?: string; +} +export default function subset({ options, log }: SubsetI): import("@esm2cjs/execa").ExecaSyncReturnValue; diff --git a/build/worker.js b/build/worker.js index 282ef68..a69cacf 100644 --- a/build/worker.js +++ b/build/worker.js @@ -1,7 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const execa_1 = require("@esm2cjs/execa"); -function subset(options) { +function subset({ options, log = "" }) { + if (log !== "") { + console.log(log); + } return (0, execa_1.execaSync)("pyftsubset", options); } exports.default = subset; diff --git a/src/main.ts b/src/main.ts index 1400b6b..693e02f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -243,7 +243,28 @@ function formatOption(format: Format) { ]; } -function getOptionInfos(fontPath = "", fontOption?: ArgOptionsT) { +function fileNameInit(nameFormat: string, fontName: string, fontExt: string) { + return nameFormat + .replace( "{NAME}", fontName) + .replace( "{EXT}", fontExt ); +} +function getFileName(initName: string, index?: number | string) { + return initName + .replace("{INDEX}", + (typeof index === "number") + ? index.toString() + : (typeof index === "string") + ? index + : "" + ); +} +function getConsoleLog(logFormat: string, origin: string, output: string) { + return logFormat + .replace("{ORIGIN}", origin) + .replace("{OUTPUT}", output); +} + +function getOptionInfos(fontPath = "", fontOption?: ArgOptionsT, indexIndicate = "") { const options: FontPipeOptionT = Object.assign( { fromCSS: "default" } satisfies Partial, getDefaultOptions(), @@ -263,6 +284,10 @@ function getOptionInfos(fontPath = "", fontOption?: ArgOptionsT) { const nameFormat = options.nameFormat; const logFormat = options.logFormat; + const initName = fileNameInit(nameFormat, fontName, fontExt); + const output = getFileName(initName, indexIndicate); + const logMsg = getConsoleLog(logFormat, fontBase, output); + const convertOption = formatOption(format); const defaultOption = options.defaultArgs; const etcOption = options.etcArgs; @@ -275,13 +300,9 @@ function getOptionInfos(fontPath = "", fontOption?: ArgOptionsT) { const worker = Worker.getInstance(); return { - fontBase, - fontName, - fontExt, - dirPath, - nameFormat, - logFormat, + initName, + logMsg, baseOption, worker, @@ -291,65 +312,6 @@ function getOptionInfos(fontPath = "", fontOption?: ArgOptionsT) { } // == Options - Others ========================================================= -function fileNameInit(nameFormat: string, fontName: string, fontExt: string) { - return nameFormat - .replace( "{NAME}", fontName) - .replace( "{EXT}", fontExt ); -} -function getFileName(initName: string, index?: number | string) { - return initName - .replace("{INDEX}", - (typeof index === "number") - ? index.toString() - : (typeof index === "string") - ? index - : "" - ); -} - -function getConsoleLog(logFormat: string, origin: string, output: string) { - return logFormat - .replace("{ORIGIN}", origin) - .replace("{OUTPUT}", output); -} - -function getSaveOption(dirPath: string, initName: string, index?: number) { - const fileName = getFileName(initName, index); - return ("--output-file=" + join(dirPath, fileName)); -} - -function getSubsetOption(fontSubsetOption?: FontSubsetOptionT) { - if( - typeof fontSubsetOption !== "undefined" && - typeof fontSubsetOption !== "string" - ) { - if("textFile" in fontSubsetOption) { - return ("--text-file=" + fontSubsetOption.textFile); - } - if("text" in fontSubsetOption) { - return ("--text=" + fontSubsetOption.text ); - } - } - return "--glyphs=*"; -} - -// == Main ===================================================================== -async function initWithLog( - dirPath: string, fontBase: string, fontName: string, fontExt: string, - nameFormat: string, logFormat: string, - index?: number | string - ) { - const initName = fileNameInit(nameFormat, fontName, fontExt); - - if(!existsSync(dirPath)) await mkdir(dirPath); - if(logFormat !== "") { - const output = getFileName(initName, index); - const log = getConsoleLog(logFormat, fontBase, output); - console.log(log); - } - return initName; -} - function getSrcInfo(src: string) { const first = src.split(",").find((str) => { return str.indexOf("url(") === 0; @@ -374,25 +336,41 @@ function getSrcInfo(src: string) { index: parseInt( parsedURL.name.split(".").pop() // google font index at latest ) + }; +} + +function getSaveOption(dirPath: string, initName: string, index?: number) { + const fileName = getFileName(initName, index); + return ("--output-file=" + join(dirPath, fileName)); +} + +function getSubsetOption(fontSubsetOption?: FontSubsetOptionT) { + if( + typeof fontSubsetOption !== "undefined" && + typeof fontSubsetOption !== "string" + ) { + if("textFile" in fontSubsetOption) { + return ("--text-file=" + fontSubsetOption.textFile); + } + if("text" in fontSubsetOption) { + return ("--text=" + fontSubsetOption.text ); + } } + return "--glyphs=*"; } +// == Main ===================================================================== export async function fontRange(fontPath = "", url = targets.korean, fontRangeOption?: FontRangeOptionT) { const { - fontBase, - fontName, - fontExt, - dirPath, - nameFormat, - logFormat, + initName, + logMsg, baseOption, worker, fromCSS - } = getOptionInfos(fontPath, fontRangeOption); - const initName = await initWithLog(dirPath, fontBase, fontName, fontExt, nameFormat, logFormat, "n"); + } = getOptionInfos(fontPath, fontRangeOption, "n"); const ranges = await parseCSS(dirPath, url); const result = ranges.map(async ({src, unicodes}, i) => { @@ -410,7 +388,8 @@ export async function fontRange(fontPath = "", url = targets.korean, fontRangeOp const unicodeOption = "--unicodes=" + unicodeRanges; const options = [fontPath, saveOption, unicodeOption, ...baseOption]; - const result: WorkerRT = await worker.run(options); + const logInfo = (i === 0) ? logMsg : ""; + const result: WorkerRT = await worker.run({ options, log: logInfo}); return result; }); @@ -419,24 +398,20 @@ export async function fontRange(fontPath = "", url = targets.korean, fontRangeOp export async function fontSubset(fontPath = "", fontSubsetOption?: FontSubsetOptionT) { const { - fontBase, - fontName, - fontExt, - dirPath, - nameFormat, - logFormat, + initName, + logMsg, baseOption, worker } = getOptionInfos(fontPath, fontSubsetOption); + if(!existsSync(dirPath)) await mkdir(dirPath); - const initName = await initWithLog(dirPath, fontBase, fontName, fontExt, nameFormat, logFormat); const subsetOption = getSubsetOption(fontSubsetOption); const saveOption = getSaveOption(dirPath, initName); const options = [fontPath, saveOption, subsetOption, ...baseOption]; - const result: WorkerRT = await worker.run(options); + const result: WorkerRT = await worker.run({ options, log: logMsg}); return result; } diff --git a/src/worker.ts b/src/worker.ts index 23b7cc3..453ec05 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -1,5 +1,12 @@ import { execaSync } from "@esm2cjs/execa"; -export default function subset(options: string[]) { +export interface SubsetI { + options: string[], + log?: string +} +export default function subset({options, log = ""}: SubsetI) { + if(log !== "") { + console.log(log); + } return execaSync("pyftsubset", options); }