Skip to content

Commit 6adfc53

Browse files
committed
Fixed deprecations
- Replaced `new Buffer()` with Buffer.from() - Declared the supported node version range in package.json
1 parent d1197f8 commit 6adfc53

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ npm-debug.log
33
.DS_Store
44
.nyc_output/
55
coverage/
6+
package-lock.json
7+
yarn.lock

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ npm-debug.log*
2222
pids
2323
test
2424
test.js
25+
yarn.lock

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = withConfigLoader(function (loadConfig) {
5656
var map
5757
var warnings = result.warnings().join('\n')
5858

59-
file.contents = new Buffer(result.css)
59+
file.contents = Buffer.from(result.css)
6060

6161
// Apply source map to the chain
6262
if (file.sourceMap) {

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"version": "8.0.0",
1717
"description": "PostCSS gulp plugin",
1818
"main": "index.js",
19+
"engines": {
20+
"node": ">=6"
21+
},
1922
"scripts": {
2023
"coveralls": "coveralls < coverage/lcov.info",
2124
"pretest": "eslint *.js",

test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ it('should transform css with multiple processors', function (cb) {
4141
})
4242

4343
stream.write(new Vinyl({
44-
contents: new Buffer('a { color: black }')
44+
contents: Buffer.from('a { color: black }')
4545
}))
4646

4747
stream.end()
@@ -64,7 +64,7 @@ it('should not transform css with out any processor', function (cb) {
6464
})
6565

6666
stream.write(new Vinyl({
67-
contents: new Buffer(css)
67+
contents: Buffer.from(css)
6868
}))
6969

7070
stream.end()
@@ -89,7 +89,7 @@ it('should correctly wrap postcss errors', function (cb) {
8989
})
9090

9191
stream.write(new Vinyl({
92-
contents: new Buffer('a {'),
92+
contents: Buffer.from('a {'),
9393
path: path.resolve('testpath')
9494
}))
9595

@@ -143,7 +143,7 @@ it('should generate source maps', function (cb) {
143143
init.write(new Vinyl({
144144
base: __dirname,
145145
path: __dirname + '/fixture.css',
146-
contents: new Buffer('a { color: black }')
146+
contents: Buffer.from('a { color: black }')
147147
}))
148148

149149
init.end()
@@ -169,7 +169,7 @@ it('should correctly generate relative source map', function (cb) {
169169
init.write(new Vinyl({
170170
base: __dirname + '/src',
171171
path: __dirname + '/src/fixture.css',
172-
contents: new Buffer('a { color: black }')
172+
contents: Buffer.from('a { color: black }')
173173
}))
174174

175175
init.end()
@@ -179,7 +179,7 @@ it('should correctly generate relative source map', function (cb) {
179179

180180
describe('PostCSS Guidelines', function () {
181181

182-
var sandbox = sinon.sandbox.create()
182+
var sandbox = sinon.createSandbox()
183183
var CssSyntaxError = function (message, source) {
184184
this.name = 'CssSyntaxError'
185185
this.message = message
@@ -241,7 +241,7 @@ describe('PostCSS Guidelines', function () {
241241
})
242242

243243
stream.write(new Vinyl({
244-
contents: new Buffer('a {}'),
244+
contents: Buffer.from('a {}'),
245245
path: cssPath
246246
}))
247247

@@ -265,7 +265,7 @@ describe('PostCSS Guidelines', function () {
265265
})
266266

267267
stream.write(new Vinyl({
268-
contents: new Buffer('a {}')
268+
contents: Buffer.from('a {}')
269269
}))
270270

271271
stream.end()
@@ -276,7 +276,7 @@ describe('PostCSS Guidelines', function () {
276276

277277
var cssPath = __dirname + '/fixture.css'
278278
var file = new Vinyl({
279-
contents: new Buffer('a {}'),
279+
contents: Buffer.from('a {}'),
280280
path: cssPath
281281
})
282282
var plugins = [ doubler ]
@@ -308,7 +308,7 @@ describe('PostCSS Guidelines', function () {
308308

309309
var cssPath = __dirname + '/fixture.css'
310310
var file = new Vinyl({
311-
contents: new Buffer('a {}'),
311+
contents: Buffer.from('a {}'),
312312
path: cssPath
313313
})
314314
var stream = postcss({ to: 'initial' })
@@ -355,7 +355,7 @@ describe('PostCSS Guidelines', function () {
355355
cb()
356356
})
357357
stream.end(new Vinyl({
358-
contents: new Buffer('a {}'),
358+
contents: Buffer.from('a {}'),
359359
path: cssPath
360360
}))
361361
})
@@ -375,7 +375,7 @@ describe('PostCSS Guidelines', function () {
375375
cb()
376376
})
377377
stream.end(new Vinyl({
378-
contents: new Buffer('a {}'),
378+
contents: Buffer.from('a {}'),
379379
path: cssPath
380380
}))
381381
})
@@ -395,7 +395,7 @@ describe('PostCSS Guidelines', function () {
395395
cb()
396396
})
397397
stream.end(new Vinyl({
398-
contents: new Buffer('a {}'),
398+
contents: Buffer.from('a {}'),
399399
path: cssPath,
400400
base: __dirname
401401
}))
@@ -432,7 +432,7 @@ describe('PostCSS Guidelines', function () {
432432
})
433433

434434
var file = new Vinyl({
435-
contents: new Buffer('a {}'),
435+
contents: Buffer.from('a {}'),
436436
path: cssPath
437437
})
438438
file.sourceMap = {}
@@ -453,7 +453,7 @@ describe('PostCSS Guidelines', function () {
453453
})
454454

455455
stream.write(new Vinyl({
456-
contents: new Buffer('a {}')
456+
contents: Buffer.from('a {}')
457457
}))
458458

459459
stream.end()
@@ -485,7 +485,7 @@ describe('PostCSS Guidelines', function () {
485485
})
486486

487487
stream.write(new Vinyl({
488-
contents: new Buffer('a {}'),
488+
contents: Buffer.from('a {}'),
489489
path: cssPath
490490
}))
491491

@@ -520,7 +520,7 @@ describe('PostCSS Guidelines', function () {
520520
})
521521

522522
stream.write(new Vinyl({
523-
contents: new Buffer('a {}'),
523+
contents: Buffer.from('a {}'),
524524
path: cssPath
525525
}))
526526

0 commit comments

Comments
 (0)