Skip to content

Commit

Permalink
fix: Use '/' path separator on Windows for tar archives (#24)
Browse files Browse the repository at this point in the history
Creating a tar archive on Windows with a directory results instead in the file having '\\' in its name,
and on extraction on POSIX, does not create the appropriate directory.

To fix this, use `path.posix` to force the '/' path separator even if creating the archive on Windows.

closes #22
  • Loading branch information
Infiltrator committed Aug 2, 2023
1 parent 674915c commit 3aa065b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/tar/stream.js
Expand Up @@ -75,12 +75,12 @@ class TarStream extends BaseStream {
files.forEach(fileOrDir => {
const newOpts = utils.clone(opts);
if (opts.ignoreBase) {
newOpts.relativePath = path.join(relativePath, fileOrDir);
newOpts.relativePath = path.posix.join(relativePath, fileOrDir);
} else {
newOpts.relativePath = path.join(relativePath, path.basename(entry), fileOrDir);
newOpts.relativePath = path.posix.join(relativePath, path.basename(entry), fileOrDir);
}
newOpts.ignoreBase = true;
this.addEntry(path.join(entry, fileOrDir), newOpts);
this.addEntry(path.posix.join(entry, fileOrDir), newOpts);
});
this._onEntryFinish();
});
Expand Down

0 comments on commit 3aa065b

Please sign in to comment.