Skip to content

Commit

Permalink
Avoid exception when running install.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Jolley committed Apr 17, 2010
1 parent 9322e6f commit 5588f29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions lib/private/core.js
Expand Up @@ -47,6 +47,9 @@ core.once = core.tiki.once;
be thrown.
*/
core.wait = function(cont, context) {

var LOOP = platform.getLoop();

var looped = false,
unlooped = false,
ret ;
Expand All @@ -63,12 +66,12 @@ core.wait = function(cont, context) {
}

unlooped = true;
if (looped) platform.unloop();
if (looped) LOOP.unloop();
};
cont.apply(context, args);

looped = true;
if (!unlooped) platform.loop(); // wait until finished
if (!unlooped) LOOP.loop(); // wait until finished
return ret;
};

Expand Down
14 changes: 9 additions & 5 deletions lib/private/platform.js
Expand Up @@ -78,12 +78,16 @@ platform.exec = function (command, echo, callback) {
});
};

var path = platform.path.join(__filename, '..', '..', '..', 'build', 'default', 'loop');
path = platform.path.normalize(path);
var LOOP = core.nativeRequire(path);
var LOOP;
exports.getLoop = function() {
if (LOOP) return LOOP;

var path = platform.path.join(__filename, '..', '..', '..', 'build', 'default', 'loop');
path = platform.path.normalize(path);
LOOP = core.nativeRequire(path);
return LOOP;
};

exports.loop = LOOP.loop;
exports.unloop = LOOP.unloop;

// ..........................................................
// STDIO
Expand Down

0 comments on commit 5588f29

Please sign in to comment.