-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify file to test from the command line #5
Comments
@diomededavid what do you mean? I guess you want to edit/comment some of the lines in gulpfile.js? |
@diomededavid I'm sure you've found this by now, but you can use yargs to pass command-line options to your gulp tasks. For example, $ gulp send --to me@mydomain.com --message email.html where function send () {
var config = {...} // where ... is your valid SMTP (or other) config
var config.to = yargs.argv.to;
var message = yargs.argv.message;
return gulp.src(message)
.pipe(gulp_mail(config))
.pipe(gulp.dest('dist'));
} You probably will want to define defaults and check for values / errors, but that's basically that. |
@justin713 Thanks. I did get it to do the test, and the entire script runs using: "gulp mail --message filename.html". I receive the email test, but all the the inlined CSS get stripped out. I am using Foundation for emails. Here is the function I am using. ` if (EMAIL) { return gulp.src('dist/**/' + message) |
@diomededavid The only thing I can recommend is to check that the file(s) being sourced by the |
@diomededavid — found this via a Google Search as I was trying to do this as well. So here is what I did to handle only sending to a specific template, for reference you'll be editing the Put this below the const TEMPLATE = yargs.argv.template; Replace your current // Send either a specified template to email for testing or just send them all.
// If no AWS creds then do not replace img urls.
// Ex: npm run mail -- --template filename.html
function mail() {
var awsURL = !!CONFIG && !!CONFIG.aws && !!CONFIG.aws.url ? CONFIG.aws.url : false;
if (TEMPLATE) {
var mailSource = 'dist/**/' + TEMPLATE;
} else {
var mailSource = 'dist/**/*.html';
}
if (EMAIL) {
CONFIG.mail.to = [EMAIL];
}
return gulp.src(mailSource)
.pipe($.if(!!awsURL, $.replace(/=('|")(\/?assets\/img)/g, "=$1"+ awsURL)))
.pipe($.mail(CONFIG.mail))
.pipe(gulp.dest('dist'));
} Then to run the new script with your specific template you'd do |
How can i specify a file I would like to test from the the command line?
The text was updated successfully, but these errors were encountered: