Skip to content

Commit 3aa065b

Browse files
authored
fix: Use '/' path separator on Windows for tar archives (#24)
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
1 parent 674915c commit 3aa065b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/tar/stream.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ class TarStream extends BaseStream {
7575
files.forEach(fileOrDir => {
7676
const newOpts = utils.clone(opts);
7777
if (opts.ignoreBase) {
78-
newOpts.relativePath = path.join(relativePath, fileOrDir);
78+
newOpts.relativePath = path.posix.join(relativePath, fileOrDir);
7979
} else {
80-
newOpts.relativePath = path.join(relativePath, path.basename(entry), fileOrDir);
80+
newOpts.relativePath = path.posix.join(relativePath, path.basename(entry), fileOrDir);
8181
}
8282
newOpts.ignoreBase = true;
83-
this.addEntry(path.join(entry, fileOrDir), newOpts);
83+
this.addEntry(path.posix.join(entry, fileOrDir), newOpts);
8484
});
8585
this._onEntryFinish();
8686
});

0 commit comments

Comments
 (0)