Permalink
Browse files

fixes to work properly with ringo

  • Loading branch information...
1 parent 8972285 commit 4165586432a3ea5c78eaad506339acf59595132e @kriszyp committed Oct 14, 2011
Showing with 22 additions and 11 deletions.
  1. +11 −4 engines/rhino/fs.js
  2. +1 −1 fs.js
  3. +4 −4 lazy-array.js
  4. +6 −2 process.js
View
15 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){
@@ -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);
@@ -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;
View
2 fs.js
@@ -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
View
8 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;
@@ -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;
View
8 process.js
@@ -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.