问题
I created a build system as an npm script, so I'm able to run npm run build -- <DIRECTORY>
. This runs the file build.js
, which packs a couple of tar archives from the specified directory and moves the resulting tar into the dist
directory.
For this I use the package node-tar:
var stream = fstream.Reader({
path: project + "/" + folder
});
stream.pipe(tar.Pack())
.pipe(fstream.Writer({ path: project + "/" + folder + ".tar" }));
Assume the following directory structure:
folder-a
test1.xml
test2.xml
dist
package.json
build.js
When running npm run build -- folder-a
, this should create a tar-archive with the contents of folder-a with the following structure:
folder-a.tar
test1.xml
test2.xml
What it does though, is the following:
folder-a.tar
folder-a
test1.xml
test2.xml
How can I get rid of the parent directory and put the files directly into the root of the archive?
来源:https://stackoverflow.com/questions/33055288/dont-include-parent-folder-when-packing-tar