From 83d1f61fd3c60fc063cbc979f6b5d1da393a2c22 Mon Sep 17 00:00:00 2001 From: Dan Mindru Date: Tue, 3 Sep 2019 23:35:04 +0200 Subject: [PATCH] Sketch look for unused task --- gulpfile.js | 13 +++---------- tasks/check-for-missing.js | 28 ++++++++++++++++++++++++++++ tasks/check-for-unused.js | 0 tasks/dupe.js | 4 +--- 4 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 tasks/check-for-missing.js create mode 100644 tasks/check-for-unused.js diff --git a/gulpfile.js b/gulpfile.js index 5d70224..b4421e2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,12 +1,7 @@ const gulp = require('gulp'); const plumber = require('gulp-plumber'); -const { - SOURCE, - DIST, - WORKING_DIR, - CONFIGURATION_FILE -} = require('./constants'); +const { SOURCE, DIST, WORKING_DIR, CONFIGURATION_FILE } = require('./constants'); const options = { source: SOURCE, @@ -27,13 +22,11 @@ require('./tasks/less')(options); require('./tasks/lint')(options); require('./tasks/postcss')(options); require('./tasks/sass')(options); +require('./tasks/check-for-missing')(options); require('./tasks/check-deps')(options); /* Runs the entire pipeline once. */ -gulp.task( - 'run-pipeline', - gulp.series('dupe', 'less', 'sass', 'postcss', 'lint', 'build') -); +gulp.task('run-pipeline', gulp.series('dupe', 'less', 'sass', 'postcss', 'lint', 'build', 'check-for-missing')); /* By default templates will be built into '/dist'. */ gulp.task( diff --git a/tasks/check-for-missing.js b/tasks/check-for-missing.js new file mode 100644 index 0000000..c4d6af3 --- /dev/null +++ b/tasks/check-for-missing.js @@ -0,0 +1,28 @@ +const gulp = require('gulp'); +const { getConfigsForDir, getFilePathsForDir } = require('./util/util'); + +function checkForMissingTask(options) { + gulp.task('check-for-missing', done => { + const configs = getConfigsForDir(options.workingDir, options.configurationFile); + + configs.map(({ dir, confItems }) => { + confItems.forEach(async confItem => { + const definedStrings = Object.keys(confItem).map(key => { + return { + src: `@echo ${key}`, + used: false + }; + }); + + const cwd = `${options.workingDir}/${dir}`; + const files = await getFilePathsForDir(cwd); + const htmlTemplates = files.filter(file => !!file.match(/.*\.html/) && !file.match(/.*\.inc*\.html/)); // Read only CSS files. + console.log(definedStrings, htmlTemplates); + }); + + done(); + }); + }); +} + +module.exports = checkForMissingTask; diff --git a/tasks/check-for-unused.js b/tasks/check-for-unused.js new file mode 100644 index 0000000..e69de29 diff --git a/tasks/dupe.js b/tasks/dupe.js index ac02b9c..46d9fe1 100644 --- a/tasks/dupe.js +++ b/tasks/dupe.js @@ -5,9 +5,7 @@ function dupeTask(options) { gulp.task('dupe', function() { del.sync([options.workingDir]); - return options - .src([options.source + '/**/*']) - .pipe(gulp.dest('./' + options.workingDir)); + return options.src([options.source + '/**/*']).pipe(gulp.dest('./' + options.workingDir)); }); }