verbose / verb

HEADS UP! Verb is going though a major transition, we've completely refactored everything from the ground up. If you're interested, please see the dev branch.
MIT License
480 stars 32 forks source link

Adding custom task #98

Open phun-ky opened 8 years ago

phun-ky commented 8 years ago

I have this in my package.json, generating a nice README.md with verb-readme-generator as devDependency and verb installed globally:

"verb": {
  "toc": true,
  "tasks": [
    "readme"
  ]
},

Is it possible to add a task (without adding a file) to produce another type of .md file? For example:

"verb": {
  "toc": true,
  "tasks": [
    "readme",
    "styleguide": {
      "includeDir": "/path/to/include other files from into .styleguide.md",
      "input": ".styleguide.md",
      "output": "/foo/bar/styleguide.md"
    }
  ]
},
jonschlinkert commented 8 years ago

without adding a file

What you're describing is idea for a plugin/generator, since you would only need to require it into plugins where it's needed, and you wouldn't need to add a file in your local project.

Example:

module.exports = function(app) {
  // setup tasks to do what you need. If a `default` task
  // is defined, verb will run it when the generator is called
  // e.g. `$ verb readme` actually runs `$ verb readme:default`
};

also, instead of defining options in the tasks array, you would want to move that to the root of the verb object, or options (it would be up to your generator or plugin):

"verb": {
  "toc": true,
  "options": {
    "styleguide": {
      "includeDir": "/path/to/include other files from into .styleguide.md",
      "input": ".styleguide.md",
      "output": "/foo/bar/styleguide.md"
    }  
 },
  "tasks": [
    "readme",
    "styleguide"
  ]
},