From 091851ee3d576d0dc97d196073dd95c38553a44f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 5 Mar 2013 09:05:02 +0100 Subject: [PATCH] First taste of node. --- src/stdlib/fs.coffee | 3 ++- src/stdlib/task-shell.coffee | 3 +++ static/index.html | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/stdlib/fs.coffee b/src/stdlib/fs.coffee index cac22e5fe..62c7d1794 100644 --- a/src/stdlib/fs.coffee +++ b/src/stdlib/fs.coffee @@ -2,6 +2,7 @@ # http://ringojs.org/api/v0.8/fs/ _ = require 'underscore' +nodeFs = nodeRequire 'fs' module.exports = # Make the given path absolute by resolving it against the @@ -90,7 +91,7 @@ module.exports = # Open, read, and close a file, returning the file's contents. read: (path) -> - $native.read(path) + String nodeFs.readFileSync(path) # Returns an array of path components. If the path is absolute, the first # component will be an indicator of the root of the file system; for file diff --git a/src/stdlib/task-shell.coffee b/src/stdlib/task-shell.coffee index 458235e56..f4e583500 100644 --- a/src/stdlib/task-shell.coffee +++ b/src/stdlib/task-shell.coffee @@ -12,6 +12,9 @@ self.console = log: -> callTaskMethod 'log', arguments... error: -> callTaskMethod 'error', arguments... +self.nodeRequire = self.require +self.require = undefined + window.document = createElement: -> setAttribute: -> diff --git a/static/index.html b/static/index.html index 0e27bf115..960344d24 100644 --- a/static/index.html +++ b/static/index.html @@ -23,6 +23,9 @@ console.error(error.stack || error); } } + + window.nodeRequire = window.require; + window.require = undefined;