From dbf59ce136a2c3348e880939d0ceaebea1865a85 Mon Sep 17 00:00:00 2001 From: Dan Mindru Date: Mon, 19 Oct 2015 03:48:29 +0200 Subject: [PATCH] Build improvements: use task cb, del to start fresh, cleaned sample data --- dist/fadeit/full-mail-dan.html | 28 -------- dist/fadeit/full-mail-lars.html | 28 -------- dist/fadeit/full-mail-sample.html | 28 ++++++++ dist/fadeit/signature-lars.html | 28 -------- dist/fadeit/signature-reply-lars.html | 28 -------- ...y-dan.html => signature-reply-sample.html} | 2 +- ...gnature-dan.html => signature-sample.html} | 2 +- dist/play/full-mail-play-lars.html | 2 +- dist/play/signature-play-lars.html | 2 +- package.json | 2 + src/fadeit/conf.js | 23 ++----- src/play/footer.inc.html | 2 +- tasks/build.js | 66 +++++++++++-------- 13 files changed, 77 insertions(+), 164 deletions(-) delete mode 100644 dist/fadeit/full-mail-dan.html delete mode 100644 dist/fadeit/full-mail-lars.html create mode 100644 dist/fadeit/full-mail-sample.html delete mode 100644 dist/fadeit/signature-lars.html delete mode 100644 dist/fadeit/signature-reply-lars.html rename dist/fadeit/{signature-reply-dan.html => signature-reply-sample.html} (93%) rename dist/fadeit/{signature-dan.html => signature-sample.html} (52%) diff --git a/dist/fadeit/full-mail-dan.html b/dist/fadeit/full-mail-dan.html deleted file mode 100644 index 956c611..0000000 --- a/dist/fadeit/full-mail-dan.html +++ /dev/null @@ -1,28 +0,0 @@ -
Hi adsadsada,
MAAAN
\ No newline at end of file diff --git a/dist/fadeit/full-mail-lars.html b/dist/fadeit/full-mail-lars.html deleted file mode 100644 index 03e0bad..0000000 --- a/dist/fadeit/full-mail-lars.html +++ /dev/null @@ -1,28 +0,0 @@ -
Hi there,
Thanks for writing up this email.
We are delighted to reply with a custom footer template.
\ No newline at end of file diff --git a/dist/fadeit/full-mail-sample.html b/dist/fadeit/full-mail-sample.html new file mode 100644 index 0000000..a10c026 --- /dev/null +++ b/dist/fadeit/full-mail-sample.html @@ -0,0 +1,28 @@ +
Hi there,
Thanks for writing up this email.
We are delighted to reply with a responsive template.
\ No newline at end of file diff --git a/dist/fadeit/signature-lars.html b/dist/fadeit/signature-lars.html deleted file mode 100644 index 6746aca..0000000 --- a/dist/fadeit/signature-lars.html +++ /dev/null @@ -1,28 +0,0 @@ -
\ No newline at end of file diff --git a/dist/fadeit/signature-reply-lars.html b/dist/fadeit/signature-reply-lars.html deleted file mode 100644 index 5f0d520..0000000 --- a/dist/fadeit/signature-reply-lars.html +++ /dev/null @@ -1,28 +0,0 @@ -
\ No newline at end of file diff --git a/dist/fadeit/signature-reply-dan.html b/dist/fadeit/signature-reply-sample.html similarity index 93% rename from dist/fadeit/signature-reply-dan.html rename to dist/fadeit/signature-reply-sample.html index 6fad5ed..da7272e 100644 --- a/dist/fadeit/signature-reply-dan.html +++ b/dist/fadeit/signature-reply-sample.html @@ -25,4 +25,4 @@ padding-bottom:20px; } } -
\ No newline at end of file +
\ No newline at end of file diff --git a/dist/fadeit/signature-dan.html b/dist/fadeit/signature-sample.html similarity index 52% rename from dist/fadeit/signature-dan.html rename to dist/fadeit/signature-sample.html index 8ed7a94..ba033f7 100644 --- a/dist/fadeit/signature-dan.html +++ b/dist/fadeit/signature-sample.html @@ -25,4 +25,4 @@ padding-bottom:20px; } } -
\ No newline at end of file +
\ No newline at end of file diff --git a/dist/play/full-mail-play-lars.html b/dist/play/full-mail-play-lars.html index 03e0bad..7cc9ee6 100644 --- a/dist/play/full-mail-play-lars.html +++ b/dist/play/full-mail-play-lars.html @@ -25,4 +25,4 @@ padding-bottom:20px; } } -
Hi there,
Thanks for writing up this email.
We are delighted to reply with a custom footer template.
\ No newline at end of file +
Hi there,
Thanks for writing up this email.
We are delighted to reply with a custom footer template.
\ No newline at end of file diff --git a/dist/play/signature-play-lars.html b/dist/play/signature-play-lars.html index 6746aca..72a7e33 100644 --- a/dist/play/signature-play-lars.html +++ b/dist/play/signature-play-lars.html @@ -25,4 +25,4 @@ padding-bottom:20px; } } -
\ No newline at end of file +
\ No newline at end of file diff --git a/package.json b/package.json index 3d2908a..77997fb 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,13 @@ }, "homepage": "https://github.com/fadeit/responsive-html-email-signature#readme", "devDependencies": { + "del": "^2.0.2", "gulp": "^3.9.0", "gulp-inline-css": "^3.0.0", "gulp-minify-html": "^1.0.4", "gulp-preprocess": "^1.2.0", "gulp-rename": "^1.2.2", + "q": "^1.4.1", "run-sequence": "^1.1.4", "wrench": "^1.5.8" } diff --git a/src/fadeit/conf.js b/src/fadeit/conf.js index 3843805..53bead6 100644 --- a/src/fadeit/conf.js +++ b/src/fadeit/conf.js @@ -1,26 +1,13 @@ module.exports = [ { - id: 'lars', - signature: 'Med venlig hilsen / best regards,', - name: 'Lars Normark Holmgaard', + id: 'sample', + signature: 'Yours truly,', + name: 'Jane Whatsmyname', welcome: 'Hi there,', - introParagraph: 'Thanks for writing up this email.
We are delighted to reply with a custom footer template.', + introParagraph: 'Thanks for writing up this email.
We are delighted to reply with a responsive template.', contactMain: 'Call 81100200 or email us at', // Wrap phone numbers like this to prevent iOS mail from making them blue. contactMail: 'info@fadeit.dk', - contactSecondary: 'Anelystparken 31D  ●  DK-8381 Tilst  ●  Aarhus
', - logoUrl: 'http://fadeit.dk/!email/fadeit-logo.png', - logoAlt: 'fadeit logo', - website: 'http://fadeit.dk' - }, - { - id: 'dan', - signature: 'Med venlig hilsen / best regards,', - name: 'Dan Mindru', - welcome: 'Hi adsadsada,', - introParagraph: 'MAAAN', - contactMain: 'Call dsadasdazzzz or email us at', // Wrap phone numbers like this to prevent iOS mail from making them blue. - contactMail: 'info@fadeit.dk', - contactSecondary: 'Anelystparken 31D  ●  DK-8381 Tilst  ●  Aarhus
', + contactSecondary: 'Anelystparken 31, DK-8381 Tilst, Aarhus', logoUrl: 'http://fadeit.dk/!email/fadeit-logo.png', logoAlt: 'fadeit logo', website: 'http://fadeit.dk' diff --git a/src/play/footer.inc.html b/src/play/footer.inc.html index 53034ae..04cc08a 100644 --- a/src/play/footer.inc.html +++ b/src/play/footer.inc.html @@ -20,7 +20,7 @@
- +
diff --git a/tasks/build.js b/tasks/build.js index c63e155..a169ed1 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -5,39 +5,47 @@ var gulp = require('gulp'), minifyHTML = require('gulp-minify-html'), preprocess = require('gulp-preprocess'), rename = require('gulp-rename'), - wrench = require('wrench'); + wrench = require('wrench'), + Q = require('q'), + del = require('del'); function buildTask(options){ - gulp.task('build', function() { + gulp.task('build', function(cb) { + var promises = [] - wrench.readdirSyncRecursive('./src').filter(function(file) { - return (!file.match('/') && !file.match(/^\.+/g)) ? file : false - }).forEach(function(dir){ - var confPath = './../' + options.src + '/' + dir + '/conf.js' - makeTemplates(dir, require(confPath)); - }); - - function makeTemplates(dir, confItems){ - confItems.forEach(function(item){ - gulp.src([options.src + '/' + dir + '/**/*.html', '!' + options.src + '/**/*.inc.html']) - .pipe(preprocess({ - context: item - })) - .pipe(inlineCss({ - applyTableAttributes: true, - applyWidthAttributes: true, - preserveMediaQueries: true, - removeStyleTags: false - })) - .pipe(minifyHTML({quotes: true})) - .pipe(rename(function rename(path){ - path.dirname = dir; - path.basename += '-' + item.id; - return path; - })) - .pipe(gulp.dest('./dist/')); + del(options.dist).then(function(){ + wrench.readdirSyncRecursive(options.src).filter(function(file) { + return (!file.match('/') && !file.match(/^\.+/g)) ? file : false + }).forEach(function(dir){ + var confPath = './../' + options.src + '/' + dir + '/conf.js'; + delete require.cache[require.resolve(confPath)] + promises.push(makeTemplates(dir, require(confPath))); }); - } + + function makeTemplates(dir, confItems){ + confItems.forEach(function(item){ + gulp.src([options.src + '/' + dir + '/**/*.html', '!' + options.src + '/**/*.inc.html']) + .pipe(preprocess({ + context: item + })) + .pipe(inlineCss({ + applyTableAttributes: true, + applyWidthAttributes: true, + preserveMediaQueries: true, + removeStyleTags: false + })) + .pipe(minifyHTML({quotes: true})) + .pipe(rename(function rename(path){ + path.dirname = dir; + path.basename += '-' + item.id; + return path; + })) + .pipe(gulp.dest(options.dist)); + }); + } + + Q.all(promises).then(function(){ cb(); }); + }); }); }