annotate backends/directory.js @ 30:b2faacfefb90

Rewrite of the module manager; fix of some modules; fix of the directory backend.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 04 Nov 2010 17:50:52 +0100
parents e007a6364bf0
children 62cbb1c49bc5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 /*
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 *
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 * This file is part of PSĜS, a PubSub server written in JavaScript.
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 *
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 * PSĜS is free software: you can redistribute it and/or modify
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 * it under the terms of the GNU Affero General Public License as
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 * License.
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 *
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 * PSĜS is distributed in the hope that it will be useful,
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 * GNU Affero General Public License for more details.
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 *
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 * You should have received a copy of the GNU Affero General Public License
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>.
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 */
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 var fs = require('fs');
29
e007a6364bf0 Fix an error when loading file/directory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 28
diff changeset
21 var Node = require('../nodes').Node;
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 var backend = exports;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 backend.save = function(dir) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 if (!dir)
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 dir = 'storage';
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 fs.stat(dir, function(err, stats) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 if (err)
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 fs.mkdir(dir, 0755);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 else if (!stats.isDirectory()) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 console.log('\033[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\033[0m');
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 process.exit(1);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 fs.readdir(dir, function(err, files) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 function sanitize(o) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 var n = {};
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 for (var i in o) {
28
7cfcd7d5796c Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 27
diff changeset
40 if (i == 'content' || o[i].setFromISO8601)
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 n[i] = o[i].toString();
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 else if (o[i] instanceof Array)
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 n[i] = o[i];
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 else if (typeof o[i] == 'object')
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 n[i] = sanitize(o[i]);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 else if (typeof o[i] == 'function')
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 ;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 else
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 n[i] = o[i];
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 return n;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 var data = sanitize(backend.list);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 var inspect = require('sys').inspect;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56
30
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
57 for (var nodeID in data)
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
58 fs.writeFile(dir+'/'+nodeID+'.json', inspect(data[nodeID], false, null));
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
59
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 var toDelete = [];
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 for (var i in files) {
30
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
63 var file = files[i];
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
64 if (!(file.replace(/\.json$/, '') in data))
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
65 toDelete.push(file);
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67
30
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
68 for (var nodeID in toDelete)
b2faacfefb90 Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 29
diff changeset
69 fs.unlink(dir+'/'+toDelete[nodeID]);
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 });
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 });
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 backend.load = function(dir) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 if (!dir)
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 dir = 'storage';
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 fs.stat(dir, function(err, stats) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 if (err)
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 fs.mkdir(dir, 0755);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81 else if (!stats.isDirectory()) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
82 console.log('\033[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\033[0m');
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
83 process.exit(1);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 fs.readdir(dir, function(err, files) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87 var xmpp = require('xmpp');
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88 function parseStanza(path, content) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 var stanza = null;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 var stream = new xmpp.Stream({
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 stanza: function (stanza) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
92 path[content] = stanza;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94 });
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95 stream.opened = true;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 stream.data(path[content]);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99 function endParsing(o) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 var regexp = /\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ/;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 for (var i in o) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 if (typeof o[i] == 'string' && i == 'content')
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 parseStanza(o, i);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 else if (typeof o[i] == 'string' && regexp(o[i])) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 var today = new Date();
28
7cfcd7d5796c Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 27
diff changeset
106 today.setFromISO8601(o[i]);
27
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107 o[i] = today;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 } else if (typeof o[i] == 'object')
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109 endParsing(o[i]);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111 return o;
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114 backend.list = {};
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 for (var i in files) {
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 var file = files[i];
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 var nodeID = file.replace(/\.json$/, '');
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 var data = fs.readFileSync(dir+'/'+file);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 var obj = eval('('+data+')');
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123 backend.list[nodeID] = endParsing(obj);
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 for (var j in Node.prototype)
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126 backend.list[nodeID][j] = Node.prototype[j];
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127 }
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 });
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129 });
a36a514e8be8 Learned that “hg addremove” can be good, sometimes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130 }