node-modules / compressing

Everything you need for compressing and uncompressing
MIT License
431 stars 36 forks source link

windows tgz and linux tar zxvf, path error #22

Closed xinggangling closed 1 year ago

xinggangling commented 5 years ago

compressing.tgz....a dir which contain dir\a.js, dir\b.js; then upload this tgz to linux, and run tar zxvf xx.tgz, the result is unexpected( dir\a.js , dir\b.js );

I think the problem is not change /\/ to / on windows; the path is at lib/tar/stream.js/_addDirEntry(); I modify like below and works well:

_addDirEntry(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).replace(/\\/g, '/');
        } else {
          newOpts.relativePath = path.join(relativePath, path.basename(entry), fileOrDir).replace(/\\/g, '/');
        }
        newOpts.ignoreBase = true;
        this.addEntry(path.join(entry, fileOrDir).replace(/\\/g, '/'), newOpts);
      });
      this._onEntryFinish();
    });
  }

I do not whether this is a good idea, or I can fix it by so config; if not; I hope this problem can fixed as soon as posibble; best wishes to you ^ _ ^

fengmk2 commented 5 years ago

can you upload the demo tgz file here? we can fix it or you can help us fix it .

xinggangling commented 5 years ago

demo.zip

this zip contain a tgz file which is used compressing.tgz compress; you can try run zxvf dist.201901071743.tgz on linux, You can find the path is not expected.

1546855114 1

rudyxu1102 commented 5 years ago

same issue

hejxing commented 4 years ago

+1

frankggyy commented 4 years ago

same issue

binperson commented 4 years ago

https://www.npmjs.com/package/@01js/compressing