Skip to content

Commit 50152d6

Browse files
authored
Merge pull request #502 from 5saviahv/dev
Write out Electron original-fs auto loading
2 parents f2148e7 + e4cb43d commit 50152d6

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

README.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
# ADM-ZIP for NodeJS with added support for electron original-fs
1+
# ADM-ZIP for NodeJS
22

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

5+
<a href="https://github.com/cthackers/adm-zip/actions/workflows/ci.yml">
6+
<img src="https://github.com/cthackers/adm-zip/actions/workflows/ci.yml/badge.svg" alt="Build Status">
7+
</a>
8+
59
# Installation
610

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

913
$ npm install adm-zip
1014

15+
**Electron** file system support described below.
16+
1117
## What is it good for?
1218

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

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

66-
[![Build Status](https://travis-ci.org/cthackers/adm-zip.svg?branch=master)](https://travis-ci.org/cthackers/adm-zip)
72+
## Electron original-fs
73+
74+
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.
75+
76+
Example:
77+
78+
```javascript
79+
const AdmZip = require("adm-zip");
80+
const OriginalFs = require("original-fs");
81+
82+
// reading archives
83+
const zip = new AdmZip("./my_file.zip", { fs: OriginalFs });
84+
.
85+
.
86+
.
87+
```

util/fattr.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
const fs = require("./fileSystem").require();
21
const pth = require("path");
32

4-
fs.existsSync = fs.existsSync || pth.existsSync;
5-
6-
module.exports = function (/*String*/ path) {
3+
module.exports = function (/*String*/ path, /*Utils object*/ { fs }) {
74
var _path = path || "",
85
_obj = newAttr(),
96
_stat = null;

util/fileSystem.js

-11
This file was deleted.

util/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fsystem = require("./fileSystem").require();
1+
const fsystem = require("fs");
22
const pth = require("path");
33
const Constants = require("./constants");
44
const Errors = require("./errors");

0 commit comments

Comments
 (0)