The tool to create artifacts for your assemblies.
Copy only the necessary files and pack them in tar.gz
file.
It works much faster than removing unnecessary files and packing with command-line utility tar
.
For example, 1 minute vs 10 seconds for project with 20 thousand files (80 Mb).
$ npm install --save tartifacts
const tartifacts = require('tartifacts');
const artifacts = [
{
dest: 'artifact.tar.gz',
includes: 'sources/**',
excludes: 'sources/exlib/**'
tar: true,
gzip: { level: 1 }
},
{
dest: 'artifact-dir',
includes: 'sources/**',
excludes: 'sources/exlib/**'
},
{
dest: 'artifact-dir',
patterns: [
'sources/**',
'!sources/exlib/**'
]
}
];
tartifacts(artifacts, {
root: __dirname, // `process.cwd()` by default
dotFiles: true, // include dotfiles
emptyFiles: true // include empty files,
emptyDirs: false // include empty directories
})
.then(() => console.log('Copying or packaging completed!'))
.catch(err => console.log(err));
Usage
$ tartifacts
Options
-i, --include Paths to inlcude files
-e, --exclude Paths to exclude files
-p, --patterns Path to file with include and exclude patterns
-d, --dest Path to destination file
-r, --root Path to root directory
Examples
$ tartifacts --include="lib/**" --exclude="node_modules/" --dest="artifact.tar.gz"
$ tartifacts --patterns="./path/to/patterns" --dest="artifact.tar.gz"
You can write patterns to file.
Use !
prefix for exclude and #
for comments.
Example:
# include `sources`
sources/**
# exclude `sources/exlib`
!sources/exlib/*.{js,css}
# override previous exclude pattern,
# and include files with `es6.js` extension
sources/exlib/*.{es6.js}
Read more about patterns in glob package.
Creates artifacts and writes them to fs.
Type: object[]
The info about artifacts.
Each artifact object has the following fields.
Type: string
The path to destination file or directory.
Type: string[]
Default: []
The paths to files which need to be included or excluded.
Read more about it in patterns section.
Type: string[]
Default: []
The paths to files which need to be included.
Type: string[]
Default: []
The paths to files which need to be excluded.
Type: boolean
Default: false
If true
, destination directory will be packed to tarball file.
Otherwise files of artifact will be copied to destination directory.
Type: boolean
, object
Default: false
If true
, tarball file will be gzipped.
Type: object
Type: string
Default: precess.cwd()
The path to root directory.
Type: boolean
Default: true
Include dotfiles.
Type: boolean
Default: true
Include empty files.
Type: boolean
Default: true
Include empty directories.
MIT © Andrew Abramov