Skip to content

Commit

Permalink
fixes to work properly with ringo
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Oct 14, 2011
1 parent 8972285 commit 4165586
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
15 changes: 11 additions & 4 deletions engines/rhino/fs.js
@@ -1,4 +1,4 @@
var File = require("file"),
var File = require("fs"),
LazyArray = require("../../lazy-array").LazyArray,
defer = require("../../promise").defer;
for(var i in File){
Expand All @@ -10,8 +10,15 @@ exports.writeFileSync = File.write;
exports.mkdirSync = File.mkdir;
exports.readdir = exports.list;
exports.stat = exports.statSync = function(path) {
try{
var stat = File.stat.apply(null, arguments);
return {
isFile: function(){
return File.isFile(path);
},
size: File.size(path)
};

/*try{
var stat = File.stat.apply(null, arguments);
}catch(e){
var deferred = defer();
deferred.reject(e);
Expand All @@ -25,7 +32,7 @@ exports.stat = exports.statSync = function(path) {
deferred.reject("File not found");
return deferred.promise;
}
return stat;
return stat;*/
}

exports.makeTree = File.mkdirs;
Expand Down
2 changes: 1 addition & 1 deletion fs.js
Expand Up @@ -2,7 +2,7 @@
* Node fs module that returns promises
*/

if (typeof system === "object" && system.engine === "rhino"){
if (typeof java === "object"){
var fs = require("./engines/rhino/fs");

// for rhino
Expand Down
8 changes: 4 additions & 4 deletions lazy-array.js
@@ -1,4 +1,4 @@
({define:typeof define!="undefined"?define:function(deps, factory){module.exports = factory.apply(this, deps.map(require))}}).
({define:typeof define!="undefined"?define:function(deps, factory){module.exports = factory.apply(this, deps.map(function(id){require(id)}))}}).
define(["./promise"], function(promise){
try{
var when = promise.when;
Expand Down Expand Up @@ -32,10 +32,10 @@ exports.get = function(array, index){
});
};


var testProto = {};
var testProto2 = testProto.__proto__ = testProto2;
var mutableProto = testProto.__proto__ === testProto2;
var testProto2 = {a:"b"};
testProto.__proto__ = testProto2;
var mutableProto = testProto.a == "b";
function SomeWrapper(hasSomeAndLength){
if(mutableProto){
hasSomeAndLength.source = hasSomeAndLength;
Expand Down
8 changes: 6 additions & 2 deletions process.js
Expand Up @@ -23,8 +23,12 @@ if(typeof process !== "undefined"){
}
}
else if(typeof navigator === "undefined"){
exports.args = require("" + "system").args;
exports.env = require("" + "system").env;
try{
exports.args = require("" + "system").args;
exports.env = require("" + "system").env;
}catch(e){
// in raw rhino, we don't even have system
}
exports.print = print;
}
});

0 comments on commit 4165586

Please sign in to comment.