-
Notifications
You must be signed in to change notification settings - Fork 80
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
A document improvement suggestion #377
Comments
Can you point me to the exact wording or send a PR to explain? I'm looking at http://linemanjs.com/#adding-tasks and it seems to explicitly call out |
Also, if you have suggestions our documentation is open source as well and would love PR's, it's here @dematic-rodrigo-silveira https://github.com/linemanjs/lineman-docs :) |
Including a suggestion on how to document the custom tasks section. You will notice that I took a different approach, by including the examples right at the text, which differs from the web-site approach, which has references to the examples; the web-site approach is fine and you could easily do the same the suggestion herein. Adding Custom TasksIntroductionLineman can easily be extended to do extra grunt-work for your application above-and-beyond the built-in grunt tasks. Lineman provides a folder for you to include custom tasks, tasks. Lineman will automatically require all files in the tasks directory and load them into Grunt. Below is a very simple custom task sample code for a task that fetches application libraries. The taskPlace this task in the tasks folder. module.exports = function(grunt) {
grunt.registerTask('install-libs', ['clean', 'exec']);
}; Note that:
The task configurationUse the application.js file, found in the configuration folder, to configure the install-libs task. module.exports = function(lineman) {
// DO NOT REMOVE
var app = lineman.config.application;
//Override application configuration here. Common examples follow in the comments.
return {
// code not included from brevity
...
// Configure the node modules used by your task, grunt-contrib-clean and grunt-exec
loadNpmTasks: lineman.config.application.loadNpmTasks.concat('grunt-contrib-clean', 'grunt-exec'),
// Configuration for the grunt-exec module to loade the backbone, bootstrap, and jquery2
exec: {
//grunt-exec tasks to load the libraries
'backbone': 'lineman fetch "backbone"',
'jquery2': 'lineman fetch "jquery2"'
},
// code not included from brevity
...
};
}; Running The TaskFrom Command LineOnce they're loaded, you can manually run the task from the command line using lineman grunt (which just delegates through to grunt): $ lineman grunt install-libraries As Part Of Your WorkflowBut you're probably more interested in adding the custom task to run along with the other tasks in lineman run and/or lineman build. You can add any task to these commands by adding it to the appropriate array under the appendTasks object in config/application.js: module.exports = function(lineman) {
// DO NOT REMOVE
var app = lineman.config.application;
//Override application configuration here. Common examples follow in the comments.
return {
// code not included from brevity
...
// Configure where to run the install-libraries task in your workflow
prependTasks: {
// Note that the task is being concatenated into the already configured common tasks
common: app.prependTasks.common.concat(["install-libraries"])
// This is incorrect and would overwrite the already configured common tasks
// common:["install-libraries"]
},
// code not included from brevity
...
};
}; Additional Workflow ConsiderationsLineman has three default workflow tasks:
Lineman offers you a mechanism to insert your custom tasks before and after each of its default tasks:
prependTasks: {
common: ["A"],
dev: ["B"],
dist: ["C"]
},
appendTasks: {
common: ["D"],
dev: ["E"],
dist: ["F"]
} In the above example, tasks "A" & "D" would run during both lineman run and lineman build. Meanwhile, "B" & "E" would run only during lineman run, while "C" & "F" would only run during lineman build. Tasks specified under prependTasks way will be run before Lineman's built-in tasks for the corresponding phase, while tasks specified under appendTasks will run immediately afterward. For reference, check out Lineman's default configuration. If you need more fine-grained control—say you want to replace or remove a default task—you can use custom JavaScript in your application config file to edit the appropriate array directly; here's an example of removing a task from the Ember.js template. |
I suggest you consider
The text was updated successfully, but these errors were encountered: