Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/commands/app/commit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type RESTPutApiAppCommitResult, Routes } from "@discloudapp/api-types/v2";
import { resolveFile } from "@discloudapp/util";
import { type ICommand } from "../../interfaces/command";

interface CommandArgs {
Expand Down Expand Up @@ -30,9 +29,9 @@ export default <ICommand<CommandArgs>>{
async run(core, args) {
const spinner = core.print.spin("Zipping files...");

const buffer = await core.fs.zip(args.glob, core.workspaceFolder);
const arrayBuffer = await core.fs.zip(args.glob, core.workspaceFolder);

const file = await resolveFile(buffer, "file.zip");
const file = new File(arrayBuffer, "file.zip");

spinner.start("Commiting...");

Expand Down
6 changes: 3 additions & 3 deletions src/commands/app/upload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type RESTPostApiUploadResult, Routes } from "@discloudapp/api-types/v2";
import { DiscloudConfig, resolveFile } from "@discloudapp/util";
import { DiscloudConfig } from "@discloudapp/util";
import { join } from "path";
import { type ICommand } from "../../interfaces/command";
import { CONFIG_FILENAME } from "../../services/discloud/constants";
Expand Down Expand Up @@ -34,9 +34,9 @@ export default <ICommand<CommandArgs>>{

const spinner = core.print.spin("Zipping files...");

const buffer = await core.fs.zip(args.glob, core.workspaceFolder);
const arrayBuffer = await core.fs.zip(args.glob, core.workspaceFolder);

const file = await resolveFile(buffer, "file.zip");
const file = new File(arrayBuffer, "file.zip");

spinner.start("Uploading...");

Expand Down
5 changes: 2 additions & 3 deletions src/commands/team/commit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type RESTPutApiAppCommitResult, Routes } from "@discloudapp/api-types/v2";
import { resolveFile } from "@discloudapp/util";
import { type ICommand } from "../../interfaces/command";

interface CommandArgs {
Expand Down Expand Up @@ -30,9 +29,9 @@ export default <ICommand<CommandArgs>>{
async run(core, args) {
const spinner = core.print.spin("Zipping files...");

const buffer = await core.fs.zip(args.glob, core.workspaceFolder);
const arrayBuffer = await core.fs.zip(args.glob, core.workspaceFolder);

const file = await resolveFile(buffer, "file.zip");
const file = new File(arrayBuffer, "file.zip");

spinner.start("Commiting...");

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface IFileSystem {
/**
* @param cwd default `process.cwd()`
*/
zip(glob: string | string[], cwd?: string): Promise<Buffer>
zip(glob: string | string[], cwd?: string): Promise<Buffer[]>

/**
* @param cwd default `process.cwd()`
Expand Down
7 changes: 2 additions & 5 deletions src/structures/filesystem/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ export default class FileSystem implements IFileSystem {
}

async zip(glob: string | string[], cwd: string = this.core.workspaceFolder) {
return Buffer.concat(await asyncGeneratorToArray(this.zipIterate(glob, cwd)));
return await asyncGeneratorToArray(this.zipIterate(glob, cwd));
}

zipIterate(glob: string | string[], cwd?: string): AsyncGenerator<Buffer>
async* zipIterate(glob: string | string[], cwd: string = this.core.workspaceFolder) {
if (Array.isArray(glob)) glob = glob.join(" ");

const encoding = "buffer";
const zipCommand = "discloud zip";

const child = spawn(zipCommand, ["-e", encoding, "-g", glob], {
const child = spawn("discloud", ["zip", "-e", "buffer", "-g", glob], {
cwd,
shell: true,
timeout: MINUTE_IN_MILLISECONDS,
Expand Down
2 changes: 1 addition & 1 deletion test/commands/zip.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ suite("Testing zip command", async () => {
* @param {OptionsWithEncoding} options
* @returns {Promise<Buffer>}
* @typedef OptionsWithEncoding
* @prop {BufferEncoding} encoding
* @prop {BufferEncoding | "buffer"} encoding
* @prop {number} [maxBuffer]
*
* @overload
Expand Down
Loading