How to use @xmcl/unzip - 5 common examples

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
return async function downloadInstaller(ctx: Task.Context) {
                    await downloadFileIfAbsentWork({
                        url: installer,
                        destination: dest,
                        checksum: {
                            hash: version.installer.sha1,
                            algorithm: "sha1",
                        },
                    })(ctx);
                    return vfs.createReadStream(dest).pipe(Unzip.createParseStream({ lazyEntries: true })).wait();
                };
            }
github Voxelum / minecraft-launcher-core-node / packages / common / index.ts View on Github external
async openFileSystem(basePath: string | Uint8Array): Promise {
        if (typeof basePath === "string") {
            const stat = await promises.stat(basePath);
            if (stat.isDirectory()) {
                return new DefaultFS(basePath);
            } else {
                const zip = await Unzip.open(basePath, { lazyEntries: false });
                return new ZipFS(basePath, zip);
            }
        } else {
            const zip = await Unzip.open(basePath as Buffer, { lazyEntries: false });
            return new ZipFS("", zip);
        }
    }
    decodeBase64(input: string): string {
github Voxelum / minecraft-launcher-core-node / packages / common / index.ts View on Github external
async openFileSystem(basePath: string | Uint8Array): Promise {
        if (typeof basePath === "string") {
            const stat = await promises.stat(basePath);
            if (stat.isDirectory()) {
                return new DefaultFS(basePath);
            } else {
                const zip = await Unzip.open(basePath, { lazyEntries: false });
                return new ZipFS(basePath, zip);
            }
        } else {
            const zip = await Unzip.open(basePath as Buffer, { lazyEntries: false });
            return new ZipFS("", zip);
        }
    }
    decodeBase64(input: string): string {
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 1 year ago

Package Health Score

59 / 100
Full package analysis