Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading Folder Doesn't Work #911

Open
TurtleP opened this issue Oct 30, 2023 · 0 comments
Open

Reading Folder Doesn't Work #911

TurtleP opened this issue Oct 30, 2023 · 0 comments

Comments

@TurtleP
Copy link

TurtleP commented Oct 30, 2023

Hi,

I might be misreading the documentation, but I'm having a hard time reading a folder that exists within my zip file. I'm loading a TOML file within the zip with a specified name, and based on one of the keys I check if the folder name exists.

export async function sendContent(archive: File): Promise<BundlerResponse> {
  const iconFiles: Record<string, Promise<Blob>> = {};
  let config: ConfigFile;

  const zip = await new JSZip().loadAsync(archive);
  const content = await zip.files["lovebrew.toml"].async("string");

  try {
    config = toml.parse(content);
    
    //  ... snip ...

    const sourceFolder: JSZip | null = zip.folder(config.build.source);
    console.log(`Source folder: ${sourceFolder?.name}`);
    console.log(`Source folder content: ${sourceFolder?.files.length}`);
  } catch (exception) {
    // handle exception
  }

  // .. snip ..
}

When I print config.build.source it does say game which is expected.

The logs in the console are showing:

Source folder: undefined and Source folder content: undefined. According to the documentation, zip.folder should be returning a JSZip which allows me to get the name, etc. I want to then iterate all files inside of this directory to perform some operations on them on a backend endpoint.

Here is the zip file I am reading, which is passed from a file pick/drop operation:
content.zip

For context, I am relatively new to using TypeScript, but I feel like I'm on the right track with what I'm doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant