build: fix small potential issue when building packs
This commit is contained in:
parent
cf9131cfe5
commit
92ed1027f4
|
@ -5,7 +5,7 @@
|
||||||
import promises from "node:fs/promises";
|
import promises from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
import { distDirectory, sourceDirectory } from "./const.js";
|
import { distDirectory } from "./const.js";
|
||||||
import { convertPackFileToJSONFile } from "./json-pack-tools.js";
|
import { convertPackFileToJSONFile } from "./json-pack-tools.js";
|
||||||
|
|
||||||
const packsDistDirectory = path.join(distDirectory, "packs");
|
const packsDistDirectory = path.join(distDirectory, "packs");
|
||||||
|
|
|
@ -40,11 +40,12 @@ function cleanPackEntry(entry, cleanSourceId = true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a JSON string containing an array to a Pack (NeDB) string.
|
* Converts JSON content containing an array to a Pack (NeDB) string.
|
||||||
* @param {string} jsonString The input JSON string
|
* @param {string | ArrayBuffer} contents The input JSON content
|
||||||
* @returns {string} The resulting Pack string
|
* @returns {Promise<string>} The resulting Pack string
|
||||||
*/
|
*/
|
||||||
export function convertJSONToPack(jsonString) {
|
export async function convertJSONToPack(contents) {
|
||||||
|
const jsonString = contents.toString();
|
||||||
return (
|
return (
|
||||||
JSON.parse(jsonString)
|
JSON.parse(jsonString)
|
||||||
.map((entry) => cleanPackEntry(entry))
|
.map((entry) => cleanPackEntry(entry))
|
||||||
|
|
Loading…
Reference in a new issue