-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1de237
commit 3adb58b
Showing
11 changed files
with
219 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
node_modules | ||
yarn.lock | ||
/dest | ||
.nyc_output | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
'use strict'; | ||
const gulp = require('gulp'); | ||
const gzip = require('gulp-gzip'); | ||
const tar = require('.'); | ||
import gulp from 'gulp'; | ||
import gzip from 'gulp-gzip'; | ||
import tar from './index.js'; | ||
|
||
exports.default = () => { | ||
export default function main() { | ||
// Tar in buffer mode | ||
gulp.src('fixture/fixture.txt') | ||
gulp.src('test/fixture/fixture.txt') | ||
.pipe(tar('test1.tar')) | ||
.pipe(gulp.dest('dest')); | ||
|
||
// Tar in stream mode | ||
gulp.src('fixture/fixture.txt', {buffer: false}) | ||
gulp.src('test/fixture/fixture.txt', {buffer: false}) | ||
.pipe(tar('test2.tar')) | ||
.pipe(gulp.dest('dest')); | ||
|
||
// Tar and gzip in buffer mode | ||
gulp.src('fixture/fixture.txt') | ||
gulp.src('test/fixture/fixture.txt') | ||
.pipe(tar('test3.tar')) | ||
.pipe(gzip()) | ||
.pipe(gulp.dest('dest')); | ||
|
||
// Tar and gzip in stream mode | ||
gulp.src('fixture/fixture.txt', {buffer: false}) | ||
gulp.src('test/fixture/fixture.txt', {buffer: false}) | ||
.pipe(tar('test4.tar')) | ||
.pipe(gzip()) | ||
.pipe(gulp.dest('dest')); | ||
|
||
// Check default parameters for tar-stream | ||
gulp.src('fixture/fixture.txt') | ||
gulp.src('test/fixture/fixture.txt') | ||
.pipe(tar('test_options.tar', {mtime: 0})) | ||
.pipe(gulp.dest('dest')); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,19 @@ | |
"description": "Create tarball from files", | ||
"license": "MIT", | ||
"repository": "sindresorhus/gulp-tar", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"test": "xo && nyc mocha" | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
|
@@ -32,20 +35,19 @@ | |
"streams" | ||
], | ||
"dependencies": { | ||
"archiver": "^3.1.1", | ||
"plugin-error": "^1.0.1", | ||
"through2": "^3.0.1", | ||
"vinyl": "^2.1.0" | ||
"archiver": "^6.0.1", | ||
"gulp-plugin-extras": "^0.3.0", | ||
"vinyl": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^5.3.1", | ||
"gulp": "^4.0.2", | ||
"gulp-gzip": "^1.2.0", | ||
"vinyl-fs": "^3.0.3", | ||
"mocha": "^6.2.0", | ||
"nyc": "^14.1.1", | ||
"rimraf": "^3.0.0", | ||
"tar-fs": "^2.0.0", | ||
"xo": "^0.24.0" | ||
"gulp-gzip": "^1.4.2", | ||
"p-event": "^6.0.0", | ||
"rimraf": "^5.0.5", | ||
"tar-fs": "^3.0.4", | ||
"vinyl-fs": "^4.0.0", | ||
"xo": "^0.56.0" | ||
}, | ||
"peerDependencies": { | ||
"gulp": ">=4" | ||
|
@@ -54,5 +56,8 @@ | |
"gulp": { | ||
"optional": true | ||
} | ||
}, | ||
"ava": { | ||
"serial": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,53 @@ | ||
/* eslint-env mocha */ | ||
const {createReadStream} = require('fs'); | ||
const path = require('path'); | ||
const zlib = require('zlib'); | ||
const assert = require('assert'); | ||
const gulp = require('gulp'); | ||
const gulpZip = require('gulp-gzip'); | ||
const tarfs = require('tar-fs'); | ||
const rimraf = require('rimraf'); | ||
const gulpTar = require('..'); | ||
import {createReadStream} from 'node:fs'; | ||
import path from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
import zlib from 'node:zlib'; | ||
import {pipeline} from 'node:stream/promises'; | ||
import test from 'ava'; | ||
import {pEvent} from 'p-event'; | ||
import gulp from 'gulp'; | ||
import gulpZip from 'gulp-gzip'; | ||
import tarfs from 'tar-fs'; | ||
import {rimrafSync} from 'rimraf'; | ||
import gulpTar from '../index.js'; | ||
|
||
it('should include directories', done => { | ||
const onTargz = () => { | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
test('should include directories', async t => { | ||
const onTargz = async () => { | ||
const filename = 'archive.tar.gz'; | ||
const fullPath = path.join(__dirname, 'dest', filename); | ||
const rs = createReadStream(fullPath); | ||
|
||
rs.pipe(zlib.createGunzip()) | ||
.pipe( | ||
tarfs.extract(path.join(__dirname, 'dest-out'), { | ||
mapStream: (filestream, header) => { | ||
const expected = expectedNames.pop(); | ||
assert.strictEqual(header.name, expected); | ||
return filestream; | ||
} | ||
}) | ||
) | ||
.on('finish', () => { | ||
for (const directory of ['dest', 'dest-out']) { | ||
rimraf.sync(path.join(__dirname, directory)); | ||
} | ||
const expectedNames = [ | ||
'dir-fixture/inside.txt', | ||
'fixture.txt', | ||
]; | ||
|
||
await pipeline( | ||
rs, | ||
zlib.createGunzip(), | ||
tarfs.extract(path.join(__dirname, 'dest-out'), { | ||
mapStream(filestream, header) { | ||
const expected = expectedNames.pop(); | ||
t.is(header.name, expected); | ||
return filestream; | ||
}, | ||
}), | ||
); | ||
|
||
done(); | ||
}); | ||
for (const directory of ['dest', 'dest-out']) { | ||
rimrafSync(path.join(__dirname, directory)); | ||
} | ||
}; | ||
|
||
const expectedNames = [ | ||
'dir-fixture/inside.txt', | ||
'fixture.txt' | ||
]; | ||
await pEvent( | ||
gulp.src('fixture/**/*', {cwd: __dirname}) | ||
.pipe(gulpTar('archive.tar')) | ||
.pipe(gulpZip()) | ||
.pipe(gulp.dest('dest', {cwd: __dirname})), | ||
'finish', | ||
); | ||
|
||
gulp | ||
.src('fixture/**/*', {cwd: __dirname}) | ||
.pipe(gulpTar('archive.tar')) | ||
.pipe(gulpZip()) | ||
.pipe(gulp.dest('dest', {cwd: __dirname})) | ||
.on('finish', onTargz); | ||
await onTargz(); | ||
}); |
Oops, something went wrong.