FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

解决zip空文件夹无法打包问题 · Issue #65 · node-modules/compressing · GitHub

解决zip空文件夹无法打包问题 #65

Description

修改 lib/zip/stream.js 文件中添加 _addDirEntry 方法如下,添加一下代码,此方法为临时修复,希望作者可以给出相应的修复方案,更新npm包
此方案只修复zip打包方式,其他打包请参考

//需要头部导入两个包
const fs = require('fs');
const utils = require('../utils');

_addDirEntry(entry, opts) {
    //先创建文件夹
    this._zipfile.addEmptyDirectory(opts.relativePath || path.basename(entry), opts);
    fs.readdir(entry, (err, files) => {
      if (err) return this.emit('error', err);
      const relativePath = opts.relativePath || '';
      files.forEach(fileOrDir => {
        const newOpts = utils.clone(opts);
        if (opts.ignoreBase) {
          newOpts.relativePath = path.join(relativePath, fileOrDir);
        } else {
          newOpts.relativePath = path.join(relativePath, path.basename(entry), fileOrDir);
        }
        newOpts.ignoreBase = true;
        this.addEntry(path.join(entry, fileOrDir), newOpts);
      });
      this._onEntryFinish();
    });
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL