Skip to main content
This release is 18 versions behind 5.0.12 — the latest version of @lost-c3/lib. Jump to latest

Lost for easy making Construct 3 Addons.

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
35%
Published
4 months ago (3.3.2)
Package root>cli>zip-addon.ts
import { join, walk, BlobWriter, ZipWriter, TextReader } from "../deps.ts"; import type { AddonType, LostConfig } from "../lib/config.ts"; import { Paths } from "../shared/paths.ts"; export default async function zipAddon(config: LostConfig<AddonType>) { const zipWriter = new ZipWriter(new BlobWriter('application/zip')); const addonFilePath = join(Paths.ProjectFolders.Builds, `${config.addonId}_${config.version}`) for await (const entry of walk(Paths.ProjectFolders.Build)) { const {isFile, path} = entry; if (isFile) { const data = await Deno.readTextFile(path); const relativePath = path.substring(Paths.ProjectFolders.Build.length + 1).replace(/\\/g, "/");; zipWriter.add(relativePath, new TextReader(data)) } } const blob = await zipWriter.close(); await Deno.writeFile(`${addonFilePath}.zip`, new Uint8Array(await blob.arrayBuffer())) await Deno.rename(`${addonFilePath}.zip`, `${addonFilePath}.c3addon`); }