yandex / tartifacts

:package: Create artifacts for your assemblies
MIT License
20 stars 9 forks source link

Transform artifacts #79

Open blond opened 7 years ago

blond commented 7 years ago

Now we can create artifact with JS object.

const tartifacts = require('tartifacts');

const artifacts = [
    {
        dest: 'artifact.tar.gz',
        includes: 'sources/**',
        excludes: 'sources/exlib/**'
        tar: true,
        gzip: { level: 1 }
    }
];

tartifacts(artifact)
    .then(() => console.log('Copying or packaging completed!'))
    .catch(err => console.log(err));

In the artifact will be added found files.

But we may need change files in artifact.

For example you may need add prefix to all files, or add files to artifact.

const tartifacts = require('tartifacts');
const rename = require('gulp-rename');
const add = require('gulp-add');

const artifact = tartifacts.tartifact({
    dest: 'artifact.tar.gz',
    includes: 'sources/**',
    excludes: 'sources/exlib/**'
    tar: true,
    gzip: { level: 1 }
})
.pipe(rename(path => { path.dirname += "/path/to/prefix"; }))
.pipe(add('filename1.txt', 'First file contents'));

tartifacts(artifact)
    .then(() => console.log('Copying or packaging completed!'))
    .catch(err => console.log(err));

The artifact created with tartifacts.tartifact should be Readable Stream with object chunks in vinyl format.

ghost commented 7 years ago

👍