Permalink
Browse files

Fixes for Node 0.4+

  • Loading branch information...
1 parent d825bb1 commit d068851043358d2d575ee3a38b69e745a874674f @temsa committed Feb 26, 2011
Showing with 19 additions and 11 deletions.
  1. +1 −1 .gitmodules
  2. +0 −1 lib/wheat.js
  3. +4 −2 lib/wheat/prettify.js
  4. +14 −7 lib/wheat/renderers.js
View
@@ -15,4 +15,4 @@
url = git://github.com/creationix/proto.git
[submodule "lib/wheat/connectpkg"]
path = lib/wheat/connectpkg
- url = git://github.com/extjs/Connect.git
+ url = git://github.com/senchalabs/Connect.git
View
@@ -19,7 +19,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
-
require.paths.unshift(__dirname + "/wheat");
require('proto');
View
@@ -55,13 +55,15 @@
// JSLint declarations
/*global console, document, navigator, setTimeout, window */
+var window = window ||{};
+window.console = console||{log:function(){}, warn:function(){}, trace:function(){}};
-if (typeof window === 'undefined') {
+/*if (typeof window === 'undefined') {
window = GLOBAL;
if (typeof require === 'function') {
window.console = console;
}
-}
+}*/
if (typeof navigator === 'undefined') {
navigator = {};
}
View
@@ -5,7 +5,7 @@ var Git = require('git-fs'),
Prettify = require('./prettify'),
MD5 = require('./md5'),
ChildProcess = require('child_process'),
- Mime = require('connect/utils').mime,
+ Mime = require('connect').utils.mime,
Step = require('step');
// Execute a child process, feed it a buffer and get a new buffer filtered.
@@ -19,6 +19,9 @@ function execPipe(command, args, data, callback) {
child.stderr.addListener('data', function onStderr(buffer) {
stderr[stderr.length] = buffer;
});
+ child.addListener('error', function onExit(err) {
+ callback(err);
+ });
child.addListener('exit', function onExit(code) {
if (code > 0) {
callback(new Error(stderr.join("")));
@@ -33,10 +36,14 @@ function execPipe(command, args, data, callback) {
callback(null, buffer);
}
});
- if (typeof data === 'string') {
- child.stdin.write(data, "binary");
- } else {
- child.stdin.write(data);
+ try {
+ if (typeof data === 'string') {
+ child.stdin.write(data, "binary");
+ } else {
+ child.stdin.write(data);
+ }
+ } catch(e) {
+ (errCallback||callback)(e);
}
child.stdin.end();
}
@@ -271,10 +278,10 @@ var Renderers = module.exports = (function(o) {
},
function processFile(err, data) {
if (err) { callback(err); return; }
- execPipe("dot", ["-Tpng"], data, this);
+ execPipe("dot", ["-Tpng"], data, this);
},
function finish(err, buffer) {
- if (err) { callback(err); return; }
+ if (err) { errCallback(err); return; }
postProcess({
"Content-Type": "image/png",
"Cache-Control": "public, max-age=32000000"

0 comments on commit d068851

Please sign in to comment.