by Marius at 1-04-2017
In times of constant change we, developers, in many cases need to repeat actions that are time consuming but not so creative. During development of a piece of software I needed to perform the following actions: The taskrunner of my choice
In times of constant change we, developers, in many cases need to repeat actions that are time consuming but not so creative. During development of a piece of software I needed to perform the following actions:
The above list of actions was triggered by any change to a file in a application source tree. Any other trigger can be set e.g. time schedule etc.
Of course there are at least few task runners. I chose Grunt, which is based on JavaScript. Grunt and its plugins are installed and managed via npm, the Node.js package manager. All you need to configure Grunt is to prepare a Gruntfile.js in which task are defined. An example of the Gruntfile is given below:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' },
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js' }
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
Other task runners:
If one likes to find out more about all above task runners there are many articles which reviews those e.g. https://blog.cozycloud.cc/technic/2014/06/18/task-runners-comparison/ or https://www.slant.co/topics/1276/~node-js-build-systems-task-runners