From 5f6103e925fec6b9b959228b137c7e6aa64f4f8a Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 19 Aug 2019 00:43:28 +0200 Subject: [PATCH] Require Node.js 8 and Gulp 4 --- .gitattributes | 3 +-- .travis.yml | 1 - gulpfile.js | 4 ++-- index.js | 19 ++++++++++--------- package.json | 19 +++++++++++-------- readme.md | 13 ++++--------- test.js | 16 ++++++++-------- 7 files changed, 36 insertions(+), 39 deletions(-) diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.travis.yml b/.travis.yml index e155464..f98fed0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,3 @@ node_js: - '12' - '10' - '8' - - '6' diff --git a/gulpfile.js b/gulpfile.js index 4576bc0..b97cf74 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,7 +3,7 @@ const gulp = require('gulp'); const gzip = require('gulp-gzip'); const tar = require('.'); -gulp.task('default', () => { +exports.default = () => { // Tar in buffer mode gulp.src('fixture/fixture.txt') .pipe(tar('test1.tar')) @@ -30,4 +30,4 @@ gulp.task('default', () => { gulp.src('fixture/fixture.txt') .pipe(tar('test_options.tar', {mtime: 0})) .pipe(gulp.dest('dest')); -}); +}; diff --git a/index.js b/index.js index eea7e27..e1b2c78 100644 --- a/index.js +++ b/index.js @@ -13,9 +13,9 @@ module.exports = (filename, options) => { let firstFile; const archive = archiver('tar', options); - return through.obj((file, enc, cb) => { + return through.obj((file, encoding, callback) => { if (file.relative === '') { - cb(); + callback(); return; } @@ -23,16 +23,17 @@ module.exports = (filename, options) => { firstFile = file; } - archive.append(file.contents, Object.assign({ + archive.append(file.contents, { name: file.relative.replace(/\\/g, '/') + (file.isNull() ? '/' : ''), mode: file.stat && file.stat.mode, - date: file.stat && file.stat.mtime ? file.stat.mtime : null - }, options)); + date: file.stat && file.stat.mtime ? file.stat.mtime : null, + ...options + }); - cb(); - }, function (cb) { + callback(); + }, function (callback) { if (firstFile === undefined) { - cb(); + callback(); return; } @@ -45,6 +46,6 @@ module.exports = (filename, options) => { contents: archive })); - cb(); + callback(); }); }; diff --git a/package.json b/package.json index ce1a6c7..0d79cf1 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "test": "xo && mocha" @@ -32,17 +32,20 @@ "streams" ], "dependencies": { - "archiver": "^1.0.0", - "plugin-error": "^0.1.2", - "through2": "^2.0.0", + "archiver": "^3.1.1", + "plugin-error": "^1.0.1", + "through2": "^3.0.1", "vinyl": "^2.1.0" }, "devDependencies": { - "gulp": "*", + "gulp": "^4.0.2", "gulp-gzip": "^1.2.0", - "mocha": "*", - "tar-stream": "^1.0.2", + "mocha": "^6.2.0", + "tar-stream": "^2.1.0", "vinyl-map": "^1.0.1", - "xo": "*" + "xo": "^0.24.0" + }, + "peerDependencies": { + "gulp": ">=4" } } diff --git a/readme.md b/readme.md index 5b03644..4fb6feb 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # gulp-tar [![Build Status](https://travis-ci.org/sindresorhus/gulp-tar.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-tar) -> Create [tarball](http://en.wikipedia.org/wiki/Tar_(computing)) from files +> Create [tarball](https://en.wikipedia.org/wiki/Tar_(computing)) from files ## Install @@ -17,7 +17,7 @@ const gulp = require('gulp'); const tar = require('gulp-tar'); const gzip = require('gulp-gzip'); -gulp.task('default', () => +exports.default = () => ( gulp.src('src/*') .pipe(tar('archive.tar')) .pipe(gzip()) @@ -28,7 +28,7 @@ gulp.task('default', () => ## API -### tar(filename, [options]) +### tar(filename, options?) #### filename @@ -38,11 +38,6 @@ Filename for the output tar archive. #### options -Type: `Object` +Type: `object` Default options passed to [Archiver](https://github.com/archiverjs/node-archiver)'s [constructor](https://archiverjs.com/docs/Archiver.html) and merged into the [data](https://archiverjs.com/docs/global.html#TarEntryData) passed to its [`append`](https://archiverjs.com/docs/Archiver.html#append) method. - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index 1849196..2deb1e9 100644 --- a/test.js +++ b/test.js @@ -8,13 +8,13 @@ const vinylMap = require('vinyl-map'); const Vinyl = require('vinyl'); const tar = require('.'); -it('should tar files in buffer mode', cb => { +it('should tar files in buffer mode', callback => { const stream = tar('test.tar'); stream.on('data', file => { assert.strictEqual(file.path, path.join(__dirname, 'fixture', 'test.tar')); assert.strictEqual(file.relative, 'test.tar'); - cb(); + callback(); }); stream.write(new Vinyl({ @@ -34,7 +34,7 @@ it('should tar files in buffer mode', cb => { stream.end(); }); -it('should tar files in stream mode', cb => { +it('should tar files in stream mode', callback => { const stream = tar('test.tar'); const stringStream1 = new Stream.Readable(); @@ -53,7 +53,7 @@ it('should tar files in stream mode', cb => { assert.strictEqual(file.relative, 'test.tar'); }); - stream.on('end', cb); + stream.on('end', callback); stream.write(new Vinyl({ cwd: __dirname, @@ -72,12 +72,12 @@ it('should tar files in stream mode', cb => { stream.end(); }); -it('should output file.contents as a Stream', cb => { +it('should output file.contents as a Stream', callback => { const stream = tar('test.tar'); stream.on('data', file => { assert(file.contents instanceof Stream, 'File contents should be a Stream object'); - cb(); + callback(); }); stream.write(new Vinyl({ @@ -90,7 +90,7 @@ it('should output file.contents as a Stream', cb => { stream.end(); }); -it.skip('should include directories', cb => { +it.skip('should include directories', callback => { const stream = tar('test.tar'); const evaluate = vinylMap(code => { @@ -101,7 +101,7 @@ it.skip('should include directories', cb => { stream.on('end', () => { assert.strictEqual(header.type, 'directory'); assert.strictEqual(header.name, 'fixture2/'); - cb(); + callback(); }); stream.resume();