Permalink
Browse files

adds gulp-unused

  • Loading branch information...
1 parent e57e140 commit 2a2a31a673c402db602da57a671c16115615d51d @jonschlinkert jonschlinkert committed May 5, 2016
Showing with 9 additions and 40 deletions.
  1. +6 −38 gulpfile.js
  2. +3 −2 package.json
View
@@ -4,10 +4,10 @@ var gulp = require('gulp');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var eslint = require('gulp-eslint');
-var through = require('through2');
+var unused = require('gulp-unused');
gulp.task('coverage', function() {
- return gulp.src(['index.js', 'lib/*.js'])
+ return gulp.src(['index.js', 'lib/**/*.js'])
.pipe(istanbul({includeUntested: true}))
.pipe(istanbul.hookRequire());
});
@@ -19,46 +19,14 @@ gulp.task('mocha', ['coverage'], function() {
});
gulp.task('eslint', function() {
- return gulp.src(['*.js', 'lib/*.js', 'test/*.js'])
+ return gulp.src(['*.js', 'lib/**/*.js', 'test/*.js', 'bin/*.js'])
.pipe(eslint())
.pipe(eslint.format());
});
-gulp.task('vars', function() {
- var plugins = require('./lib/plugins');
- var utils = require('./lib/utils');
- var keys = Object.keys(utils).concat(Object.keys(plugins));
- var report = {};
- var cache = {};
-
- return gulp.src(['index.js', 'lib/**/*.js', 'bin/*.'])
- .pipe(through.obj(function(file, enc, next) {
- var str = file.contents.toString();
- keys.forEach(function(key) {
- report[key] = report[key] || 0;
- var re = cache[key] || (cache[key] = new RegExp('\\.' + key, 'g'));
- var m = str.match(re);
- if (!m) return;
- report[key]++;
- });
-
- next(null, file);
- }, function(next) {
- var keys = Object.keys(report);
- var res = {};
-
- keys.sort(function(a, b) {
- return report[a] > report[b] ? -1 : 1;
- });
-
- keys.forEach(function(key) {
- res[key] = report[key];
- });
-
- console.log(res);
- console.log(keys.length, 'modules');
- next();
- }))
+gulp.task('unused', function() {
+ return gulp.src(['index.js', 'lib/**/*.js', 'bin/*.js'])
+ .pipe(unused({keys: Object.keys(require('./lib/utils.js'))}))
});
gulp.task('default', ['mocha', 'eslint']);
View
@@ -45,8 +45,8 @@
"extend-shallow": "^2.0.1",
"fs-exists-sync": "^0.1.0",
"global-modules": "^0.2.1",
- "isobject": "^2.0.0",
- "lazy-cache": "^1.0.3",
+ "isobject": "^2.1.0",
+ "lazy-cache": "^2.0.1",
"log-utils": "^0.1.4",
"minimist": "^1.2.0",
"mixin-deep": "^1.1.3",
@@ -72,6 +72,7 @@
"gulp-istanbul": "^0.10.3",
"gulp-mocha": "^2.2.0",
"gulp-prettify": "^0.4.0",
+ "gulp-unused": "^0.1.2",
"is-buffer": "^1.1.3",
"kind-of": "^3.0.2",
"load-pkg": "^3.0.1",

0 comments on commit 2a2a31a

Please sign in to comment.