Skip to content

Commit

Permalink
Merge pull request #58 from euforic/TIMOB-15009
Browse files Browse the repository at this point in the history
[TIMOB-15009] cannot see Alloy.Globals in modules when using LiveView
  • Loading branch information
Michael Xia committed Sep 25, 2013
2 parents d63b5c2 + 68477af commit c2f4df3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion lib/fserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,30 @@ FServer.start = function(opts) {
});

if (uri === '/app.js') {

var scope = detect(out.data);

// TODO probably a better way to do this, but this fix will work for now.

out.data = String(out.data).replace(/^#![^\n]*\n/, '').split('');

var v = Object.keys(scope.lexvars['']);

v.forEach(function (vr) {
var start = scope.lexvars[''][vr].parent.start;
out.data[start] = ' ';
out.data[start + 1] = ' ';
out.data[start + 2] = ' ';
});
out.data = out.data.join('');


debug('[LiveView] app.js global variables: ', scope.locals[''], '\n');

scope.locals[''].forEach(function(lexVar){
out.data = 'lvGlobal._globalCtx.' + lexVar + ' = ' + lexVar + '; ' + out.data;
out.data = out.data + '\nlvGlobal._globalCtx.' + lexVar + ' = ' + lexVar + ';';
});

response.write(out.data);
response.end();
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"chokidar": "~0.6.2",
"coloring": "~0.1.0",
"debug": "~0.7.2",
"jsparse-tools": "~0.0.1"
"jsparse-tools": "~0.1.0"
},
"devDependencies": {
"should": "~1.2.2",
Expand Down

0 comments on commit c2f4df3

Please sign in to comment.