Skip to content

Commit b89f4ff

Browse files
dpilafiantracker1
authored andcommitted
Update js to es6 and verify with jshint
1 parent 4983c32 commit b89f4ff

File tree

4 files changed

+230
-76
lines changed

4 files changed

+230
-76
lines changed

index.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
/* jshint node: true */
2-
'use strict';
3-
41
/**
52
* Module dependencies.
63
*/
74

8-
var Concat = require('concat-with-sourcemaps');
9-
var through = require('through2');
10-
var lodashTemplate = require('lodash.template');
11-
var stream = require('stream');
12-
var path = require('path');
13-
var fs = require('fs');
5+
const Concat = require('concat-with-sourcemaps');
6+
const through = require('through2');
7+
const lodashTemplate = require('lodash.template');
8+
const stream = require('stream');
9+
const path = require('path');
1410

1511
/**
1612
* gulp-header plugin
1713
*/
1814

19-
module.exports = function(headerText, data) {
15+
module.exports = (headerText, data) => {
2016
headerText = headerText || '';
2117

2218
function TransformStream(file, enc, cb) {
2319
// format template
24-
var filename = path.basename(file.path);
25-
var template =
26-
data === false
27-
? headerText
20+
const filename = path.basename(file.path);
21+
const template =
22+
data === false ?
23+
headerText
2824
: lodashTemplate(headerText)(
2925
Object.assign({}, file.data || {}, { file: file, filename: filename }, data)
3026
);
@@ -42,7 +38,7 @@ module.exports = function(headerText, data) {
4238

4339
// handle file stream;
4440
if (file.isStream()) {
45-
var stream = through();
41+
const stream = through();
4642
stream.write(Buffer.from(template));
4743
stream.on('error', this.emit.bind(this, 'error'));
4844
file.contents = file.contents.pipe(stream);
@@ -51,7 +47,7 @@ module.exports = function(headerText, data) {
5147
}
5248

5349
// variables to handle direct file content manipulation
54-
var concat = new Concat(true, filename);
50+
const concat = new Concat(true, filename);
5551

5652
// add template
5753
concat.add(null, Buffer.from(template));
@@ -82,14 +78,14 @@ module.exports = function(headerText, data) {
8278
/**
8379
* is stream?
8480
*/
85-
function isStream(obj) {
81+
const isStream = (obj) => {
8682
return obj instanceof stream.Stream;
87-
}
83+
};
8884

8985
/**
9086
* Is File, and Exists
9187
*/
92-
function isExistingFile(file) {
88+
const isExistingFile = (file) => {
9389
try {
9490
if (!(file && typeof file === 'object')) return false;
9591
if (file.isDirectory()) return false;
@@ -98,4 +94,4 @@ function isExistingFile(file) {
9894
if (typeof file.contents === 'string') return true;
9995
} catch (err) {}
10096
return false;
101-
}
97+
};

package-lock.json

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@
88
"directories": {
99
"test": "test"
1010
},
11+
"jshintConfig": {
12+
"esversion": 8,
13+
"strict": "implied",
14+
"undef": true,
15+
"unused": true,
16+
"mocha": true,
17+
"node": true
18+
},
1119
"scripts": {
20+
"pretest": "jshint *.js test",
1221
"test": "mocha --reporter spec",
1322
"publish-major": "npm version major && git push origin master && git push --tags",
1423
"publish-minor": "npm version minor && git push origin master && git push --tags",
@@ -51,6 +60,7 @@
5160
},
5261
"devDependencies": {
5362
"gulp": "^4.0.0",
63+
"jshint": "*",
5464
"mocha": "*",
5565
"should": "*",
5666
"vinyl": "*"

0 commit comments

Comments
 (0)