Permalink
Browse files

support for grunt 0.4.x

  • Loading branch information...
1 parent 0ba8d8b commit 8039f1deffd49a514d35bf3c12f9a139ae2ecf36 @bustardcelly committed Feb 28, 2013
Showing with 83 additions and 58 deletions.
  1. +1 −0 .gitignore
  2. +61 −0 Gruntfile.js
  3. +0 −41 grunt.js
  4. +5 −2 package.json
  5. +16 −15 tasks/forever-task.js
View
@@ -4,3 +4,4 @@ node_modules
npm-debug.log
forever.log
forever/*
+deprecated.*
View
@@ -0,0 +1,61 @@
+/*
+ * grunt-forever
+ * https://github.com/bustardcelly/grunt-forever
+ *
+ * Copyright (c) 2013 Todd Anderson
+ * Licensed under the MIT license.
+ * https://github.com/bustardcelly/grunt-forever/blob/master/LICENSE-MIT
+ */
+/*global module:false*/
+module.exports = function(grunt) {
+
+ 'use strict';
+ grunt.initConfig({
+ jshint: {
+ all: ['Gruntfile.js', 'tasks/**/*.js', 'test/**/*.js'],
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ boss: true,
+ eqnull: true,
+ node: true,
+ es5: true
+ }
+ },
+ watch: {
+ all: {
+ files: ['<%= jshint.all %>'],
+ tasks: ['jshint', 'nodeunit'],
+ options: {interrupt: true}
+ }
+ },
+ nodeunit: {
+ tests: ['test/*_test.js']
+ },
+ forever: {
+ main: './test/fixtures/index.js'
+ }
+
+ });
+
+ // Actually load this plugin's task(s).
+ grunt.loadTasks('tasks');
+
+ // These plugins provide necessary tasks.
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-nodeunit');
+ grunt.loadNpmTasks('grunt-contrib-internal');
+
+ // By default, lint and run all tests.
+ grunt.registerTask('test', ['nodeunit']);
+ grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
+
+ // grunt.registerHelper('forever', function(operation) {
+ // grunt.task.run('forever:' + operation);
+ // });
+
+};
View
@@ -1,41 +0,0 @@
-module.exports = function(grunt) {
- 'use strict';
-
- grunt.initConfig({
- test: {
- files: ['test/*_test.js']
- },
- lint: {
- all: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
- },
- watch: {
- files: '<config:lint.files>',
- tasks: 'default'
- },
- jshint: {
- options: {
- curly: true,
- eqeqeq: true,
- immed: true,
- newcap: true,
- noarg: true,
- sub: true,
- boss: true,
- eqnull: true,
- node: true,
- es5: true
- }
- },
- forever: {
- main: './test/fixtures/index.js'
- }
- });
-
- grunt.loadTasks('tasks');
- grunt.registerTask('default', 'lint test');
-
- grunt.registerHelper('forever', function(operation) {
- grunt.task.run('forever:' + operation);
- });
-
-};
View
@@ -1,7 +1,7 @@
{
"name": "grunt-forever",
"description": "Grunt task for starting and stopping an application as a daemon using forever",
- "version": "0.2.1",
+ "version": "0.4.0",
"homepage": "https://github.com/bustardcelly/grunt-forever",
"author": {
"name": "Todd Anderson",
@@ -31,7 +31,10 @@
"forever": ">=0.10.0"
},
"devDependencies": {
- "grunt": "~0.3.16"
+ "grunt": "~0.4.0",
+ "grunt-contrib-jshint": "~0.2.0",
+ "grunt-contrib-nodeunit": "~0.1.2",
+ "grunt-contrib-internal": "~0.4.3"
},
"keywords": [
"forever",
View
@@ -56,6 +56,7 @@ function findProcessWithIndex( index, callback ) {
}
process = undefined;
}
+
callback.call(null, process);
});
}
@@ -71,7 +72,7 @@ function findProcessWithIndex( index, callback ) {
function startForeverWithIndex( index ) {
log( 'Attempting to start ' + index + ' as daemon.');
- done = this.async;
+ done = this.async();
findProcessWithIndex( index, function(process) {
// if found, be on our way without failing.
if( typeof process !== 'undefined' ) {
@@ -97,7 +98,7 @@ function startForeverWithIndex( index ) {
* Attempts to stop a process previously started associated with index.
* @param {String} index Filename associated with previously started process.
*/
-function stopOnProcess( index ) {
+function stopOnProcess(index) {
log( 'Attempting to stop ' + index + '...' );
done = this.async();
@@ -136,18 +137,18 @@ function restartOnProcess( index ) {
done = this.async();
findProcessWithIndex( index, function(process) {
- if( typeof process !== 'undefined' ) {
- log( forever.format(true,[process]) );
+ if(typeof process !== 'undefined') {
+ log(forever.format(true,[process]));
- forever.restart( index )
+ forever.restart( ndex)
.on('error', function(message) {
- error( 'Error restarting ' + index + '. [REASON] :: ' + message );
+ error('Error restarting ' + index + '. [REASON] :: ' + message);
done(false);
});
done();
}
else {
- log( index + ' not found in list of processes in forever. Starting new instance...' );
+ log(index + ' not found in list of processes in forever. Starting new instance...');
startRequest();
done();
}
@@ -158,24 +159,24 @@ function restartOnProcess( index ) {
* grunt-future task
* @param {Object} grunt Grunt
*/
-module.exports = function( grunt ) {
+module.exports = function(grunt) {
gruntRef = grunt;
- grunt.registerTask( 'forever', 'Starts node app as a daemon.', function() {
+ grunt.registerTask( 'forever', 'Starts node app as a daemon.', function(target) {
- var index = grunt.config('forever.main') || 'index.js',
- operation = this.args[0];
+ var index = grunt.config('forever.main') || 'index.js',
+ operation = target;
try {
- if( commandMap.hasOwnProperty(operation) ) {
+ if(commandMap.hasOwnProperty(operation)) {
commandMap[operation].call( this, index );
}
else {
- warn( 'Operation ' + operation + ' is not supported currently. Only forever:start, forever:stop or forever:restart.' );
+ warn('Operation ' + operation + ' is not supported currently. Only forever:start, forever:stop or forever:restart.');
}
}
- catch( e ) {
- error( 'Exception thrown in attempt to ' + operation + ' on ' + index + ': ' + e );
+ catch(e) {
+ error('Exception thrown in attempt to ' + operation + ' on ' + index + ': ' + e);
}
});
};

0 comments on commit 8039f1d

Please sign in to comment.