diff --git a/processors.ttl b/processors.ttl index e2768e8..20ec872 100644 --- a/processors.ttl +++ b/processors.ttl @@ -29,6 +29,10 @@ js:GlobRead a js:JsProcess; a fnom:PositionParameterMapping ; fnom:functionParameter "closeOnEnd"; fnom:implementationParameterPosition "3"^^xsd:integer + ], [ + a fnom:PositionParameterMapping ; + fnom:functionParameter "binary"; + fnom:implementationParameterPosition "4"^^xsd:integer ] ]. @@ -56,6 +60,11 @@ js:GlobRead a js:JsProcess; sh:name "closeOnEnd"; sh:datatype xsd:boolean; sh:maxCount 1 + ], [ + sh:path js:binary; + sh:name "binary"; + sh:datatype xsd:boolean; + sh:maxCount 1 ]. js:FolderRead a js:JsProcess; diff --git a/src/FileUtils.ts b/src/FileUtils.ts index 6928472..ee1b0d6 100644 --- a/src/FileUtils.ts +++ b/src/FileUtils.ts @@ -9,13 +9,14 @@ export async function globRead( globPattern: string, writer: Writer, wait: number = 0, - closeOnEnd: boolean = true + closeOnEnd: boolean = true, + binary: boolean = false ) { const jsfiles = await glob(globPattern, {}); const files = await Promise.all( jsfiles.map((x) => { console.log(`[globRead] reading file ${x} (from glob pattern ${globPattern})`); - return readFile(x) + return readFile(x, binary ? {} : { encoding: "utf8" }); }), ); diff --git a/tests/Processors.test.ts b/tests/Processors.test.ts index a8d34a4..e6f6858 100644 --- a/tests/Processors.test.ts +++ b/tests/Processors.test.ts @@ -30,7 +30,8 @@ describe("File Utils tests", () => { js:glob "./*"; js:output ; js:wait 0; - js:closeOnEnd true. + js:closeOnEnd true; + js:binary true. `; const source: Source = { @@ -45,13 +46,14 @@ describe("File Utils tests", () => { const argss = extractSteps(env, quads, config); expect(argss.length).toBe(1); - expect(argss[0].length).toBe(4); + expect(argss[0].length).toBe(5); - const [[glob, output, wait, closeOnEnd]] = argss; + const [[glob, output, wait, closeOnEnd, binary]] = argss; expect(glob).toBe("./*"); testWriter(output); expect(wait).toBe(0); expect(closeOnEnd).toBeTruthy(); + expect(binary).toBeTruthy(); await checkProc(env.file, env.func); });