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

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

Open
mazhaoshuo opened this issue Jan 18, 2022 · 0 comments
Open

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

mazhaoshuo opened this issue Jan 18, 2022 · 0 comments

Comments

@mazhaoshuo
Copy link

修改 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();
    });
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant