Skip to content

Commit

Permalink
Added lab configs to node and fromFile
Browse files Browse the repository at this point in the history
  • Loading branch information
aultac committed Mar 30, 2024
1 parent e83a898 commit e5c18e7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion convert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@modusjs/convert",
"version": "1.0.6",
"version": "1.0.7",
"packageManager": "[email protected]",
"description": "Universal library for interacting with Modus XML files",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions convert/src/browser/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function isBrowserInputFile(obj: any): obj is BrowserInputFile {
}

// Trying to get the universal typings to work even thought the browser/node API is different (and node doesn't have File)
export async function fromFile(files: any | any[]) {
export async function fromFile(files: any | any[], labConfigs?: LabConfig[]) {
if (!Array.isArray(files)) {
files = [files];
}
const browser_files = files.filter(isBrowserInputFile) as BrowserInputFile[];
return fromFileBrowser(browser_files);
return fromFileBrowser(browser_files, labConfigs);
}

export async function fromFileBrowser(
Expand Down Expand Up @@ -175,4 +175,4 @@ async function readFileAsArrayBuffer(f: File): Promise<ArrayBuffer> {
};
return reader.readAsArrayBuffer(f);
});
}
}
8 changes: 5 additions & 3 deletions convert/src/node/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs/promises';
import debug from 'debug';
import { csv, json } from '../index.js';
import prompts from 'prompts';
import { LabConfig } from '../labs/index.js';

import {
save as universalSave,
Expand Down Expand Up @@ -46,7 +47,7 @@ function isNodeInputFile(obj: any): obj is NodeInputFile {
return true;
}

export async function fromFile(files: any | any[]) {
export async function fromFile(files: any | any[], labConfigs?: LabConfig[]) {
if (!Array.isArray(files)) {
files = [files];
}
Expand All @@ -56,7 +57,8 @@ export async function fromFile(files: any | any[]) {
}

export async function fromFileNode(
files: NodeInputFile | NodeInputFile[]
files: NodeInputFile | NodeInputFile[],
labConfigs?: LabConfig[]
): Promise<json.ModusJSONConversionResult[]> {
if (!Array.isArray(files)) {
files = [files];
Expand Down Expand Up @@ -100,7 +102,7 @@ export async function fromFileNode(
);
// Await all the promises that are reading files, and then filter any nulls (i.e. files skipped)
const toconvert = await Promise.all(toconvert_promises);
return json.toJson(toconvert.filter((f) => !!f) as json.InputFile[]);
return json.toJson(toconvert.filter((f) => !!f) as json.InputFile[], labConfigs);
}

// We'll make a node-specific version of save here that
Expand Down

0 comments on commit e5c18e7

Please sign in to comment.