Skip to content

Commit

Permalink
Stop using new Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rm committed Aug 29, 2018
1 parent d1f21aa commit 0d03909
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
node_js:
- '0.12'
- '6.0.0'
- '4'
- 'lts/*'
- 'node'
sudo: false
env:
global:
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ gulp.task('metadata', function () {
}).get();
var jsonFile = new Vinyl({
path: 'metadata.json',
contents: new Buffer(JSON.stringify(data))
contents: Buffer.from(JSON.stringify(data))
});
this.push(jsonFile);
this.push(file);
Expand Down Expand Up @@ -286,6 +286,10 @@ Or you can go further and reduce the size by removing the `<use>` element, like
## Changelog
* 7.0.0
* Stop using deprecated `new Buffer()` api
* Drop support for node 0.12
* 6.1.1
* Removed dependency on gulp-util to support gulp 4
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = function (config) {
for (var nsName in namespaces) {
$combinedSvg.attr(nsName, namespaces[nsName])
}
var file = new Vinyl({ path: fileName, contents: new Buffer($.xml()) })
var file = new Vinyl({ path: fileName, contents: Buffer.from($.xml()) })
this.push(file)
cb()
}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"sinon": "^1.16.1",
"wd": "^0.4.0"
},
"engines" : { "node" : ">=4.0" },
"engineStrict": true,
"keywords": [
"gulpplugin",
"svg",
Expand Down
38 changes: 19 additions & 19 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer('<svg viewBox="0 0 4 4" preserveAspectRatio="xMinYMid meet"><circle cx="2" cy="2" r="1"/></svg>')
contents: Buffer.from('<svg viewBox="0 0 4 4" preserveAspectRatio="xMinYMid meet"><circle cx="2" cy="2" r="1"/></svg>')
, path: 'circle.svg'
}))

stream.write(new Vinyl({
contents: new Buffer('<svg><rect x="1" y="1" width="2" height="2"/></svg>')
contents: Buffer.from('<svg><rect x="1" y="1" width="2" height="2"/></svg>')
, path: 'square.svg'
}))

Expand All @@ -157,7 +157,7 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer('<svg viewBox="0 0 4 4"><circle cx="2" cy="2" r="1"/></svg>')
contents: Buffer.from('<svg viewBox="0 0 4 4"><circle cx="2" cy="2" r="1"/></svg>')
, path: 'circle.svg'
}))

Expand All @@ -167,7 +167,7 @@ describe('gulp-svgstore unit test', function () {
}))

stream.write(new Vinyl({
contents: new Buffer('not an svg')
contents: Buffer.from('not an svg')
, path: 'square.svg'
}))

Expand All @@ -191,7 +191,7 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg viewBox="0 0 4 4">' +
'<defs><circle id="circ" cx="2" cy="2" r="1"/></svg></defs>' +
'<circle cx="2" cy="2" r="1"/>' +
Expand All @@ -214,8 +214,8 @@ describe('gulp-svgstore unit test', function () {
done()
})

stream.write(new Vinyl({ contents: new Buffer('<svg></svg>'), path: 'circle.svg' }))
stream.write(new Vinyl({ contents: new Buffer('<svg></svg>'), path: 'circle.svg' }))
stream.write(new Vinyl({ contents: Buffer.from('<svg></svg>'), path: 'circle.svg' }))
stream.write(new Vinyl({ contents: Buffer.from('<svg></svg>'), path: 'circle.svg' }))

stream.end()

Expand All @@ -231,13 +231,13 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer('<svg/>')
contents: Buffer.from('<svg/>')
, path: 'src/icons/circle.svg'
, base: 'src/icons'
}))

stream.write(new Vinyl({
contents: new Buffer('<svg/>')
contents: Buffer.from('<svg/>')
, path: 'src2/icons2/square.svg'
, base: 'src2/icons2'
}))
Expand All @@ -256,13 +256,13 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer('<svg/>')
contents: Buffer.from('<svg/>')
, path: 'circle.svg'
, base: '.'
}))

stream.write(new Vinyl({
contents: new Buffer('<svg/>')
contents: Buffer.from('<svg/>')
, path: 'src2/icons2/square.svg'
, base: 'src2'
}))
Expand All @@ -284,15 +284,15 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg">' +
'<rect width="1" height="1"/>' +
'</svg>')
, path: 'rect.svg'
}))

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"' +
'viewBox="0 0 50 50">' +
'<rect id="a" width="50" height="10"/>' +
Expand Down Expand Up @@ -320,14 +320,14 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>'
)
, path: 'rect.svg'
}))

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>'
)
, path: 'sandwich.svg'
Expand All @@ -351,7 +351,7 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:lk="http://www.w3.org/1999/xlink">' +
'<rect id="a" width="1" height="1"/>' +
'<use y="2" lk:href="#a"/>' +
Expand All @@ -360,7 +360,7 @@ describe('gulp-svgstore unit test', function () {
}))

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"' +
'viewBox="0 0 50 50">' +
'<rect id="a" width="50" height="10"/>' +
Expand Down Expand Up @@ -389,7 +389,7 @@ describe('gulp-svgstore unit test', function () {
})

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1998/xlink">' +
'<rect id="a" width="1" height="1"/>' +
'<use y="2" xlink:href="#a"/>' +
Expand All @@ -398,7 +398,7 @@ describe('gulp-svgstore unit test', function () {
}))

stream.write(new Vinyl({
contents: new Buffer(
contents: Buffer.from(
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"' +
'viewBox="0 0 50 50">' +
'<rect id="a" width="50" height="10"/>' +
Expand Down

0 comments on commit 0d03909

Please sign in to comment.