Skip to content

Commit

Permalink
Merge pull request #502 from 5saviahv/dev
Browse files Browse the repository at this point in the history
Write out Electron original-fs auto loading
  • Loading branch information
cthackers committed Jun 12, 2024
2 parents f2148e7 + e4cb43d commit 50152d6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
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

0 comments on commit 50152d6

Please sign in to comment.