A Grunt-Plugin to handle lockfiles within Grunt, currently just wraps lockSync of https://www.npmjs.org/package/lockfile
This plugin requires Grunt ~0.4.2
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-lock-extended --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-lock-extended');
This modul was forked from https://github.com/evangelion1204/grunt-lock. I had some issues with handling lockfile with multi-thread processes.
If you are looking for a simple and easy to use lockfile-wrapper, i recommend grunt-lock.
lockfile: {
your_target: {
path: 'yourname.lck',
//you can add one task to be ignored by the lockfile task. - i use it for an unlock task with email-reporting
ignored: [
'taskToIgnore1',
'taskToIgnore2'
],
//only allowed tasks can create a lockfile - other tasks will fail fatal
allowed: [
'taskToAllow1',
'taskToAllow2'
],
//if true, just the fails and warnings are logged
quiet: true|false
}
}
The path where your lockfile will be created
a string or an array of tasknames that will be ignored creating a lockfile
a string or an array of tasknames. Only there tasks will be able to run, if this option is set
STFU for this module. Just log what is really necessary!
To ensure the lockfile-task is invoked everytime you use grunt, you should add the following code right after grunt.initConfig()
grunt.task.run('lockfile');
{
"user": "currentUser",
"pid": 12345,
"tasks": ["theExecutedTask"],
"created": "<creation time of lockfile in SQL-Format>"
}
This Module is supposed to be used on multiuser-systems. The generated lockfile will contain information about the invoking task. The Task adds the option "parentPid" with the current pid to the grunt-options. That allows us to start childprocesses, in which the current lockfile will not prevent execution.
To allow a childprocess the execucting user and the given parentPid have to match the ones in lockfile.
In your project's Gruntfile, add a section named lockfile
to the data object passed into grunt.initConfig()
.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
This plugin was inspired by https://github.com/evangelion1204/grunt-lock