Permalink
Browse files

[plugin] Updated plugins to use new `drone` namespace

  • Loading branch information...
1 parent cef2a92 commit aada07b549b3ad8e83cb783e4a91d339540a5a94 @Marak Marak committed Jun 10, 2012
Showing with 27 additions and 22 deletions.
  1. +11 −5 lib/plugins/chdir.js
  2. +6 −6 lib/plugins/coffee.js
  3. +5 −6 lib/plugins/heartbeat.js
  4. +5 −5 lib/plugins/setuid.js
View
@@ -1,13 +1,19 @@
var path = require('path');
-module.exports = function chdirPlugin(carapace) {
- if (!carapace.chdir) {
- carapace.chdir = function (value, done) {
+module.exports = function chdirPlugin(drone) {
+ if (!drone.chdir) {
+ drone.chdir = function (value, done) {
+
try { process.chdir(path.resolve(value)) }
catch (ex) { return done ? done(ex) : null }
- carapace.cli.defaultOptions['chdir'].default = value;
- carapace.cli.defaultOptions['chdir'].required = true;
+ drone.cli.defaultOptions['chdir'].default = value;
+ drone.cli.defaultOptions['chdir'].required = true;
+
+ if (drone.debug) {
+ console.log('The current working directory of ' + drone.script + ' has been changed to ' + path.resolve(value));
+ }
+
return done ? done() : null;
};
}
View
@@ -1,20 +1,20 @@
var path = require('path'),
fs = require('fs');
-module.exports = function coffeePlugin(carapace) {
- if (!carapace.coffee) {
- carapace.coffee = function (value, done) {
+module.exports = function coffeePlugin(drone) {
+ if (!drone.coffee) {
+ drone.coffee = function (value, done) {
var coffeeBin = fs.realpathSync(path.join(process.execPath, '..', 'coffee'));
//
// This will be immediately called when this plugin is passed to `.use()`
//
// Should change `process.argv[1]` to coffee and then rewrite the CLI arguments
// as necessary so that the .coffee is handled correctly by the `coffee` binary.
//
- var script = carapace.script;
+ var script = drone.script;
function replaceWithCoffee() {
- carapace.script = coffeeBin;
- carapace.argv.unshift(script);
+ drone.script = coffeeBin;
+ drone.argv.unshift(script);
}
if (value == 'true' || /\.coffee$/.test(script)) {
replaceWithCoffee();
View
@@ -4,8 +4,8 @@
var enabled = false;
-module.exports = function (carapace) {
- carapace.heartbeat = function heartbeat() {
+module.exports = function (drone) {
+ drone.heartbeat = function heartbeat() {
var args = Array.prototype.slice.call(arguments),
interval = 1000,
done;
@@ -28,17 +28,16 @@ module.exports = function (carapace) {
// make sure we have/set the interval
//
if (!interval) {
- interval = carapace.cli.defaultOptions['heartbeat'].default;
+ interval = drone.cli.defaultOptions['heartbeat'].default;
}
else {
- carapace.cli.defaultOptions['heartbeat'].default = interval;
+ drone.cli.defaultOptions['heartbeat'].default = interval;
}
-
//
// start the timer
//
this.interval = setInterval(function () {
- carapace.emit('heartbeat', carapace.id);
+ drone.emit('heartbeat', { pid: drone.id, script: drone.script });
}, interval);
return done ? done() : null;
View
@@ -1,13 +1,13 @@
var path = require('path');
-module.exports = function setuidPlugin(carapace) {
- if (!carapace.setuid) {
- carapace.setuid = function (value, done) {
+module.exports = function setuidPlugin(drone) {
+ if (!drone.setuid) {
+ drone.setuid = function (value, done) {
try { process.setuid(value) }
catch (ex) { return done ? done(ex) : null }
- carapace.cli.defaultOptions['setuid'].default = value;
- carapace.cli.defaultOptions['setuid'].required = true;
+ drone.cli.defaultOptions['setuid'].default = value;
+ drone.cli.defaultOptions['setuid'].required = true;
return done ? done() : null;
};
}

0 comments on commit aada07b

Please sign in to comment.