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

Write out Electron original-fs auto loading #502

Merged
merged 2 commits into from
Jun 12, 2024
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
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# ADM-ZIP for NodeJS with added support for electron original-fs
# ADM-ZIP for NodeJS

ADM-ZIP is a pure JavaScript implementation for zip data compression for [NodeJS](https://nodejs.org/).

<a href="https://github.com/cthackers/adm-zip/actions/workflows/ci.yml">
<img src="https://github.com/cthackers/adm-zip/actions/workflows/ci.yml/badge.svg" alt="Build Status">
</a>

# Installation

With [npm](https://www.npmjs.com/) do:

$ npm install adm-zip

**Electron** file system support described below.

## What is it good for?

The library allows you to:
Expand Down Expand Up @@ -63,4 +69,19 @@ zip.writeZip(/*target file name*/ "/home/me/files.zip");

For more detailed information please check out the [wiki](https://github.com/cthackers/adm-zip/wiki).

[![Build Status](https://travis-ci.org/cthackers/adm-zip.svg?branch=master)](https://travis-ci.org/cthackers/adm-zip)
## Electron original-fs

ADM-ZIP has supported electron **original-fs** for years without any user interractions but it causes problem with bundlers like rollup etc. For continuing support **original-fs** or any other custom file system module. There is possible specify your module by **fs** option in ADM-ZIP constructor.

Example:

```javascript
const AdmZip = require("adm-zip");
const OriginalFs = require("original-fs");

// reading archives
const zip = new AdmZip("./my_file.zip", { fs: OriginalFs });
.
.
.
```
5 changes: 1 addition & 4 deletions util/fattr.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const fs = require("./fileSystem").require();
const pth = require("path");

fs.existsSync = fs.existsSync || pth.existsSync;

module.exports = function (/*String*/ path) {
module.exports = function (/*String*/ path, /*Utils object*/ { fs }) {
var _path = path || "",
_obj = newAttr(),
_stat = null;
Expand Down
11 changes: 0 additions & 11 deletions util/fileSystem.js

This file was deleted.

2 changes: 1 addition & 1 deletion util/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fsystem = require("./fileSystem").require();
const fsystem = require("fs");
const pth = require("path");
const Constants = require("./constants");
const Errors = require("./errors");
Expand Down