How to use the @xmcl/unzip.open function in @xmcl/unzip

To help you get started, we’ve selected a few @xmcl/unzip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Voxelum / minecraft-launcher-core-node / packages / forge-installer / index.ts View on Github external
async function findMainClass(lib: string) {
    const zip = await Unzip.open(lib, { lazyEntries: true });
    const [manifest] = await zip.filterEntries(["META-INF/MANIFEST.MF"]);
    let mainClass: string | undefined;
    if (manifest) {
        const content = await zip.readEntry(manifest).then((b) => b.toString());
        const mainClassPair = content.split("\n").map((l) => l.split(": ")).filter((arr) => arr[0] === "Main-Class")[0];
        if (mainClassPair) {
            mainClass = mainClassPair[1].trim();
        }
    }
    zip.close();
    return mainClass;
}
github Voxelum / minecraft-launcher-core-node / packages / forge-installer / index.ts View on Github external
await context.execute(async function installForgeJson() {
                const zip = await Unzip.open(jarPath, { lazyEntries: true });
                const [versionEntry] = await zip.filterEntries(["version.json"]);

                if (versionEntry) {
                    const buf = await zip.readEntry(versionEntry);
                    const raw = JSON.parse(buf.toString());
                    const id = raw.id;
                    fullVersion = id;
                    const rootPath = mc.getVersionRoot(fullVersion);
                    realJarPath = mc.getLibraryByPath(Version.getLibraryInfo(raw.libraries.find((l: any) => l.name.startsWith("net.minecraftforge:forge"))).path);

                    await vfs.ensureDir(rootPath);
                    const jsonPath = join(rootPath, `${id}.json`);
                    if (await vfs.missing(jsonPath)) {
                        await vfs.writeFile(jsonPath, buf);
                    }
                } else {

@xmcl/unzip

A easy unzip interface based on yauzl

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis