build: fix small potential issue when building packs

This commit is contained in:
Johannes Loher 2022-02-13 00:00:34 +01:00
parent cf9131cfe5
commit 92ed1027f4
2 changed files with 6 additions and 5 deletions

View file

@ -5,7 +5,7 @@
import promises from "node:fs/promises";
import path from "node:path";
import { distDirectory, sourceDirectory } from "./const.js";
import { distDirectory } from "./const.js";
import { convertPackFileToJSONFile } from "./json-pack-tools.js";
const packsDistDirectory = path.join(distDirectory, "packs");

View file

@ -40,11 +40,12 @@ function cleanPackEntry(entry, cleanSourceId = true) {
}
/**
* Converts a JSON string containing an array to a Pack (NeDB) string.
* @param {string} jsonString The input JSON string
* @returns {string} The resulting Pack string
* Converts JSON content containing an array to a Pack (NeDB) string.
* @param {string | ArrayBuffer} contents The input JSON content
* @returns {Promise<string>} The resulting Pack string
*/
export function convertJSONToPack(jsonString) {
export async function convertJSONToPack(contents) {
const jsonString = contents.toString();
return (
JSON.parse(jsonString)
.map((entry) => cleanPackEntry(entry))