Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

[error/question/help] Running mailgun taks from a taks folder. #15

Open
marocas opened this issue Jun 20, 2017 · 0 comments
Open

[error/question/help] Running mailgun taks from a taks folder. #15

marocas opened this issue Jun 20, 2017 · 0 comments

Comments

@marocas
Copy link

marocas commented Jun 20, 2017

Hello, im getting this error after i separated my tasks from gruntfile.js to a folder _tasks, ATM im using grunt-load-configs and grunt-load-tasks on my project.
Since i made this change, mailgun stopped working.

// _tasks/mailgun.js
module.exports = {
  mailer: {
    options: {
      key: '<%= cfg.email.key %>',
      sender: '<%= cfg.email.sender %>',
      recipient: '<%= cfg.email.recipient %>',
      subject: '<%= cfg.email.subject %>'
    },
    src: ['html/email.html)] 
// it send the email test but the task never stop running,  i have to cancel it with ctrl+c. 

    src: ['<%= cfg.dist %>'+grunt.option('template')] 
// cmd line : grunt send --template=email.html, i use this method to send test email.
and i get the error below.
  }
}; 
Loading _workflow/_tasks/mailgun.js...Loading "Gruntfile.js" tasks...ERROR
>> ReferenceError: grunt is not defined
>>     at Object.<anonymous> (C:\sites\bymailer\_workflow\_tasks\mailgun.js:9:29)
>>     at Module._compile (module.js:460:26)
>>     at Object.Module._extensions..js (module.js:478:10)
>>     at Module.load (module.js:355:32)
>>     at Function.Module._load (module.js:310:12)
>>     at Module.require (module.js:365:17)
>>     at require (module.js:384:17)
>>     at C:\sites\bymailer\node_modules\load-grunt-configs\lib\load-grunt-configs.js:72:30
>>     at Array.forEach (native)
>>     at module.exports (C:\sites\bymailer\node_modules\
load-grunt-configs\lib\load-grunt-configs.js:53:11)

Running tasks: send
>> [no-notifications] title: BY_Mailer
>> [no-notifications] message: Task "send" not found.
Warning: Task "send" not found. Use --force to continue.

If i change my module.exports like this to correct the missing grunt call:

// _tasks/mailgun.js
module.exports = function(grunt) {
  mailer: {
    options: {
      key: '<%= cfg.email.key %>',
      sender: '<%= cfg.email.sender %>',
      recipient: '<%= cfg.email.recipient %>',
      subject: '<%= cfg.email.subject %>'
    },
    src: ['<%= cfg.dist %>'+grunt.option('template')]
 // cmd line : grunt send --template=email.html
  }
}; 

i get this error:

Loading _workflow/_tasks/mailgun.js...Loading "Gruntfile.js" tasks...ERROR
>> C:\sites\bymailer\_workflow\_tasks\mailgun.js:5
>>       sender : '<%= cfg.email.sender %>',
>>                 ^

My taks worked fine on Gruntfile.js like this:

// gruntfile.js
'use strict';

module.exports = function(grunt) {

  var globalConfig = {
    cfg: globalConfig,
    email: {
      key:        'key-xpto',
      sender:     '[email protected]',
      recipient:  '[email protected]', 
    },
  };

  grunt.initConfig({

      cfg: globalConfig,
      pkg: grunt.file.readJSON('package.json'),

      // Use Mailgun option if you want to email the design to your inbox or to something like Litmus
      mailgun: {
        mailer: {
          options: {
            key:        '<%= cfg.email.key %>',         // Enter your Mailgun API key here
            sender:     '<%= cfg.email.sender %>',      // Change this
            recipient:  '<%= cfg.email.recipient %>',   // Change this
            subject:    '<%= cfg.email.subject %>'      // Change this
          },
          src: ['html/'+grunt.option('template')]
        }
      },

  });

  grunt.registerTask('send', ['mailgun']);
};

I must be missing something here, can you help me?

Best regards.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant