Giter Site home page Giter Site logo

Comments (4)

anseki avatar anseki commented on June 14, 2024

Thank you for your post.

Sorry, but I can't understand "task handler" and "target handler".
Is "task handler" "handlerByTask" ? and is "target handler" "handlerByFile"?
If handlerByTask returns false, exit current task immediately, and the remaining handlers are not called. If it returns true, the remaining handlers are called.

If you mean Targets in Configuration, you can control it via specifying like grunt task1:target1 or grunt task1.

from grunt-task-helper.

6aKa avatar 6aKa commented on June 14, 2024

"task handler" - handler which defined in task option.
"target handler" - handler which defined in task target option.

taskHelper: {
  options: {
    handlerByTask: function(options) {
      console.log('[global]handlerByTask'); //task handler
      return true;
    },
     filesArray: [ ]
  },
  js: {
    options: {
      handlerByTask: function(options) {
        console.log('[js]handlerByTask'); //target handler
        return true;
      },
      filesArray: [ ]
    },
    files: [
      { '<%= app.js.src %>/require.js': '<%= bower %>/requirejs/require.js' },
      { expand: true, cwd: '<%= bower %>/bootstrap/js/', src: '**/*.js', dest: '<%= app.js.src %>/bootstrap/' },
      { '<%= app.js.src %>/jquery/jquery.cookie.js': '<%= bower %>/jquery.cookie/jquery.cookie.js' }
    ]
  },
  less: {
    options: {
      filesArray: [ ]
    },
    files: [{ expand: true, cwd: '<%= bower %>/bootstrap/less/', src: '**/*.less', dest: '<%= app.scss.src %>/bootstrap/' }]
  }
},

baka@gentoo ~/test $ grunt taskHelper
Running "taskHelper:js" (taskHelper) task
[js]handlerByTask

Running "taskHelper:less" (taskHelper) task
[global]handlerByTask

Done, without errors.

This is a first type - "target handler" or "task handler".
Call "target handler", if not exist - call "task handler"

I want second type "task handler" and "target handler"
Call "task handler" if exist and that call "target handler" if exist.

Like this

baka@gentoo ~/test $ grunt taskHelper
Running "taskHelper:js" (taskHelper) task
[global]handlerByTask
[js]handlerByTask

Running "taskHelper:less" (taskHelper) task
[global]handlerByTask

Done, without errors.

from grunt-task-helper.

anseki avatar anseki commented on June 14, 2024

Ok, I understand it.
But this is mechanism of Grung.
See http://gruntjs.com/configuring-tasks#options

Target-level options will override task-level options.

The plugin get an options that was already overridden by Grunt.
I think, it might be able to access to options that isn't overridden via getting raw configuring Object. but it may break overriding mechanism of Grung. And in standard usage, it is strange processing.

So, you can specify a same handler which always run.

function globalHandler(options) {
  console.log('globalHandler');
  return true;
}

taskHelper: {
  js: {
    options: {
      handlerByTask: [
        globalHandler,
        function(options) {
          console.log('[js]handlerByTask'); //target handler
          return true;
        }
      ]
    }
  },
  less: {
    options: {
      handlerByTask: globalHandler
    }
  }
}
Running "taskHelper:js" (taskHelper) task
globalHandler
[js]handlerByTask

Running "taskHelper:less" (taskHelper) task
globalHandler

Done, without errors.

handlerByFileSrc, handlerByFile and handlerByContent can too.

from grunt-task-helper.

6aKa avatar 6aKa commented on June 14, 2024

I understand, that bad idea. And not in ideology of grunt.

from grunt-task-helper.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.