File: modules/roole.js

Recommend this page to a friend!
  Classes of Thomas Björk   Node.js Background Jobs   modules/roole.js   Download  
File: modules/roole.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: 3 years ago
Size: 920 bytes
 

Contents

Class file image Download
exports.UExecute = function(parts) { return false; }; exports.TExecute = function(parts, client) { var ast, compiler, css, e, nodeRoole, parser, s; nodeRoole = true; try { s = require.resolve("roole-compiler"); if (s.length === 0) { nodeRoole = false; } s = require.resolve("roole-parser"); if (s.length === 0) { nodeRoole = false; } } catch (_error) { e = _error; nodeRoole = false; } if (nodeRoole) { parser = require('roole-parser'); compiler = require('roole-compiler'); ast = parser.parse(parts[1]); css = compiler.compile(ast); client.write(css); client.end(); } else { client.write("404: Roole not available"); client.end(); } }; exports.Unload = function() { var name = require.resolve('roole-compiler'); delete require.cache[name]; var name = require.resolve('roole-parser'); delete require.cache[name]; }