Mercurial > psgxs
comparison modules.js @ 56:99bd1d1ac071
Migration to node-xmpp, done!
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 10 Aug 2011 15:11:22 -0700 |
parents | 0d3f18bb1d36 |
children | addbf6bbfaa8 |
comparison
equal
deleted
inserted
replaced
55:fd69d35cf2e6 | 56:99bd1d1ac071 |
---|---|
29 var Script = process.binding('evals').Script; | 29 var Script = process.binding('evals').Script; |
30 var fdsq = require('./fdsq'); | 30 var fdsq = require('./fdsq'); |
31 var sandbox = { | 31 var sandbox = { |
32 process: process, | 32 process: process, |
33 config: require('./configuration'), | 33 config: require('./configuration'), |
34 xmpp: require('xmpp'), | 34 Element: require('ltx').Element, |
35 uuid: require('uuid'), | |
35 errors: require('./errors'), | 36 errors: require('./errors'), |
36 forms: require('./forms'), | 37 forms: require('./forms'), |
37 makeError: require('./errors').makeError, | 38 makeError: require('./errors').makeError, |
38 notifs: require('./notifs'), | 39 notifs: require('./notifs'), |
39 NS: require('./namespaces'), | 40 NS: require('./namespaces'), |
40 require: require, | 41 require: require, |
41 storage: require('./storage'), | 42 storage: require('./storage'), |
42 makeRandomId: fdsq.makeRandomId, | |
43 JID: { | 43 JID: { |
44 toBare: fdsq.toBare, | 44 toBare: fdsq.toBare, |
45 toResource: fdsq.toResource | 45 toResource: fdsq.toResource |
46 }, | 46 }, |
47 exports: {} | 47 exports: {} |
52 if (!regex.test(file)) | 52 if (!regex.test(file)) |
53 continue; | 53 continue; |
54 | 54 |
55 fs.readFile(dir + '/' + file, function(err, data) { | 55 fs.readFile(dir + '/' + file, function(err, data) { |
56 if (err) { | 56 if (err) { |
57 console.log('ERROR: loading module “'+file+'”.'); // FIXME: file is always the last file of the list… | 57 console.log('Erreur de chargement de module.'); |
58 return; | 58 return; |
59 } | 59 } |
60 | 60 |
61 Script.runInNewContext(data, sandbox, dir + '/' + file); // FIXME: the same. | 61 Script.runInNewContext(data, sandbox, dir + '/' + file); |
62 var module = sandbox.exports; | 62 var module = sandbox.exports; |
63 sandbox.exports = {}; | 63 sandbox.exports = {}; |
64 | 64 |
65 for (var j in module) { | 65 for (var j in module) { |
66 if (typeof modules[j] != 'undefined') | 66 if (typeof modules[j] != 'undefined') |
67 console.log('WARNING: module '+j+' already loaded.'); | 67 console.log('WARNING: module '+j+' already loaded.'); |
68 | 68 |
69 modules[j] = module[j]; | 69 modules[j] = module[j]; |
70 console.log('Module '+j+' loaded!'); | |
70 } | 71 } |
71 }); | 72 }); |
72 } | 73 } |