Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on deprecated gulp-util #151

Merged
merged 2 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const replaceVariable = require('./replace-variable')
const concat = require('concat-stream')
const setIndent = require('./indent')
const through = require('through2')
const gutil = require('gulp-util')
const Vinyl = require('vinyl')
const PluginError = require('plugin-error')
const extend = require('extend')
const path = require('path')
const fs = require('fs')
Expand Down Expand Up @@ -46,15 +47,15 @@ module.exports = function(opts) {
data = include(file, String(data))
cb(null, data)
} catch (e) {
cb(new gutil.PluginError('gulp-file-include', e.message))
cb(new PluginError('gulp-file-include', e.message))
}
}))
} else if (file.isBuffer()) {
try {
file = include(file, String(file.contents))
cb(null, file)
} catch (e) {
cb(new gutil.PluginError('gulp-file-include', e.message))
cb(new PluginError('gulp-file-include', e.message))
}
}
}
Expand Down Expand Up @@ -150,7 +151,7 @@ module.exports = function(opts) {
includeContent = applyFilters(includeContent, args.input)
}

var recFile = new gutil.File({
var recFile = new Vinyl({
cwd: process.cwd(),
base: file.base,
path: includePath,
Expand Down Expand Up @@ -205,7 +206,7 @@ module.exports = function(opts) {
includeContent = applyFilters(includeContent, args.input)
}

var recFile = new gutil.File({
var recFile = new Vinyl({
cwd: process.cwd(),
base: file.base,
path: includePath,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
"concat-stream": "^1.6.0",
"extend": "^3.0.1",
"flatnest": "^1.0.0",
"gulp-util": "^3.0.8",
"through2": "^2.0.3"
"plugin-error": "^0.1.2",
"through2": "^2.0.3",
"vinyl": "^2.1.0"
},
"eslintConfig": {
"extends": [
Expand Down
12 changes: 6 additions & 6 deletions test/edge-case.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

const fileIncludePlugin = require('..')
const gutil = require('gulp-util')
const Vinyl = require('vinyl')
const should = require('should')
const fs = require('fs')

describe('## gulp-file-include', () => {
describe('# edge cases', () => {
it('should escape included content to avoid recursive includes', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-edge-case/index.html',
contents: fs.createReadStream('test/fixtures-edge-case/index.html')
})
Expand All @@ -28,7 +28,7 @@ describe('## gulp-file-include', () => {
})

it('should work without trailing newline', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-edge-case/without-trailing-newline.txt',
contents: fs.createReadStream('test/fixtures-edge-case/without-trailing-newline.txt')
})
Expand All @@ -48,7 +48,7 @@ describe('## gulp-file-include', () => {
})

it('should skip commented includes', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-edge-case/commented-inclusion.html',
contents: fs.createReadStream('test/fixtures-edge-case/commented-inclusion.html')
})
Expand All @@ -68,7 +68,7 @@ describe('## gulp-file-include', () => {
})

it('should give an error on recursive includes', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-edge-case/recursion.html',
contents: fs.createReadStream('test/fixtures-edge-case/recursion.html')
})
Expand All @@ -85,7 +85,7 @@ describe('## gulp-file-include', () => {
})

// it('should give an error on circular recursive includes', function(done) {
// var file = new gutil.File({
// var file = new Vinyl({
// path: 'test/fixtures-edge-case/a.html',
// contents: fs.createReadStream('test/fixtures-edge-case/a.html')
// });
Expand Down
9 changes: 5 additions & 4 deletions test/error.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict'

const fileIncludePlugin = require('..')
const gutil = require('gulp-util')
const Vinyl = require('vinyl')
const fs = require('fs')
const os = require('os')

require('should')

describe('## error', () => {
it('# if statement', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-error/if.html',
contents: fs.readFileSync('test/fixtures-error/if.html')
})
Expand All @@ -26,7 +27,7 @@ describe('## error', () => {
})

it('# for statement', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-error/if.html',
contents: fs.readFileSync('test/fixtures-error/for.html')
})
Expand All @@ -36,7 +37,7 @@ describe('## error', () => {
basepath: '@root'
})
stream.on('error', error => {
error.message.should.equal('invalid is not defined: for (var i = 0; i < invalid.length; i++) { result+=`\n <label>`+invalid[i]+`</label>\n `; }')
error.message.should.equal('invalid is not defined: for (var i = 0; i < invalid.length; i++) { result+=`' + os.EOL + ' <label>`+invalid[i]+`</label>' + os.EOL + ' `; }')
done()
})
stream.write(file)
Expand Down
12 changes: 6 additions & 6 deletions test/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const fileIncludePlugin = require('..')
const markdown = require('markdown')
const gutil = require('gulp-util')
const Vinyl = require('vinyl')
const should = require('should')
const fs = require('fs')

Expand All @@ -11,7 +11,7 @@ describe('## gulp-file-include', () => {

describe('# options - filters', () => {
it('file - filters: markdown', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures/index-markdown.html',
contents: fs.readFileSync('test/fixtures/index-markdown.html')
})
Expand All @@ -35,7 +35,7 @@ describe('## gulp-file-include', () => {
})

it('stream - filters: markdown', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures/index-markdown.html',
contents: fs.createReadStream('test/fixtures/index-markdown.html')
})
Expand All @@ -59,7 +59,7 @@ describe('## gulp-file-include', () => {
})

it('file - filters: markdown & rot13', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures/index-markdown-rot13.html',
contents: fs.readFileSync('test/fixtures/index-markdown-rot13.html')
})
Expand All @@ -84,7 +84,7 @@ describe('## gulp-file-include', () => {
})

it('stream - filters: markdown & rot13', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures/index-markdown-rot13.html',
contents: fs.createReadStream('test/fixtures/index-markdown-rot13.html')
})
Expand All @@ -109,7 +109,7 @@ describe('## gulp-file-include', () => {
})

it('file - filters: custom filter handler options', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures/index-handler-options.html',
contents: fs.createReadStream('test/fixtures/index-handler-options.html')
})
Expand Down
6 changes: 3 additions & 3 deletions test/flatten.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const fileIncludePlugin = require('..')
const gutil = require('gulp-util')
const Vinyl = require('vinyl')
const should = require('should')
const fs = require('fs')

Expand All @@ -10,7 +10,7 @@ describe('## gulp-file-include', () => {

describe('# flatten variables', () => {
it('file', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-flatten/index.html',
contents: fs.readFileSync('test/fixtures-flatten/index.html')
})
Expand All @@ -36,7 +36,7 @@ describe('## gulp-file-include', () => {
})

it('stream', done => {
var file = new gutil.File({
var file = new Vinyl({
path: 'test/fixtures-flatten/index.html',
contents: fs.createReadStream('test/fixtures-flatten/index.html')
})
Expand Down
Loading