diff --git a/README.md b/README.md index e73aeb1..61f6212 100644 --- a/README.md +++ b/README.md @@ -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/). + + Build Status + + # 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: @@ -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 }); +. +. +. +``` diff --git a/util/fattr.js b/util/fattr.js index 163e2e5..720b827 100644 --- a/util/fattr.js +++ b/util/fattr.js @@ -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; diff --git a/util/fileSystem.js b/util/fileSystem.js deleted file mode 100644 index dee5c2a..0000000 --- a/util/fileSystem.js +++ /dev/null @@ -1,11 +0,0 @@ -exports.require = function () { - if (typeof process === "object" && process.versions && process.versions["electron"]) { - try { - const originalFs = require("original-fs"); - if (Object.keys(originalFs).length > 0) { - return originalFs; - } - } catch (e) {} - } - return require("fs"); -}; diff --git a/util/utils.js b/util/utils.js index 784ae0a..cd09692 100644 --- a/util/utils.js +++ b/util/utils.js @@ -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");