2021-11-30 17:30:25 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
import promises from "node:fs/promises";
|
|
|
|
import path from "node:path";
|
|
|
|
|
2022-02-13 00:00:34 +01:00
|
|
|
import { distDirectory } from "./const.js";
|
2021-11-30 17:30:25 +01:00
|
|
|
import { convertPackFileToJSONFile } from "./json-pack-tools.js";
|
|
|
|
|
|
|
|
const packsDistDirectory = path.join(distDirectory, "packs");
|
2022-01-31 15:13:32 +01:00
|
|
|
const packsSourceDirectory = "packs";
|
2021-11-30 17:30:25 +01:00
|
|
|
|
|
|
|
console.log(`Converting pack files in ${packsDistDirectory} to json files in ${packsSourceDirectory}:`);
|
|
|
|
|
|
|
|
const conversionPromises = (await promises.readdir(packsDistDirectory, { withFileTypes: true }))
|
2022-01-31 15:13:32 +01:00
|
|
|
.filter((dirent) => dirent.isFile() && path.extname(dirent.name) === ".db")
|
2021-11-30 17:30:25 +01:00
|
|
|
.map(async (dirent) => convertPackFileToJSONFile(path.join(packsDistDirectory, dirent.name), packsSourceDirectory));
|
|
|
|
|
|
|
|
await Promise.all(conversionPromises);
|