File: modules/coffee.js

Recommend this page to a friend!
  Classes of Thomas Björk  >  Node.js Background Jobs  >  modules/coffee.js  >  Download  
File: modules/coffee.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Node.js Background Jobs
Run background jobs using Node.js modules
Author: By
Last change: Added an AutoReloadModule function that automatically reloads a module when it changes.
Added the Unload functions to modules which loads modules of its own.
Date: 2 months ago
Size: 671 bytes
 

Contents

Class file image Download
exports.UExecute = function(parts) {
  return false;
};

exports.TExecute = function(parts, client) {
  var coffee, e, html, nodeCoffee, s;
  nodeCoffee = true;
  try {
    s = require.resolve("coffee-script");
    if (s.length === 0) {
      nodeCoffee = false;
    }
  } catch (_error) {
    e = _error;
    nodeCoffee = false;
  }
  if (nodeCoffee) {
    coffee = require("coffee-script");
    html = coffee.compile(parts[1]);
    client.write(html);
    client.end();
  } else {
    client.write("404: Coffee-Script not available");
    client.end();
  }
};

exports.Unload = function() {
  var name = require.resolve('coffee-script');
  delete require.cache[name];
}