What node version is this designed for?
I've been having some problems with version v0.12.1 distributed in the upstream Arch Linux repos, though v0.10.38 has had no problems.
I started this 6 months ago and then only v0.10 was available, but I don't think it should be difficult to adapt to v0.12 if there are any issue.
Cool. I'm going to try to update everything. For now, here are the outputs of the incompatible scripts.
date.js
util.js:0
(function (exports, require, module, __filename, __dirname) { // Copyright Joy
RangeError: Maximum call stack size exceeded
at isFunction (util.js)
at formatValue (util.js:217:7)
at formatValue (util.js:224:13)
at formatValue (util.js:224:13)
at formatValue (util.js:224:13)
at formatValue (util.js:224:13)
at formatValue (util.js:224:13)
at formatValue (util.js:224:13)
at formatValue (util.js:224:13)
at formatValue (util.js:224:13)
ls.js
_common.js cat.js cd.js date.js echo.js grep.js index.js ls.js sort.js /home/aaron/coreutils.js/lib/_common.js:122
else if(chunk.inspect)
^
TypeError: Cannot read property 'inspect' of undefined
at InspectStream._transform (/home/aaron/coreutils.js/lib/_common.js:122:18)
at InspectStream.Transform._read (_stream_transform.js:179:10)
at InspectStream.Transform._write (_stream_transform.js:167:12)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:288:5)
at InspectStream.Writable.write (_stream_writable.js:217:11)
at ls.ondata (_stream_readable.js:540:20)
at ls.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at ls.Readable.push (_stream_readable.js:126:10)
:+1: inspect() is done so it can be output its content on the REPL as a result, but I'm thinking to remove it since it couldn't work for streams, that probably is a better API for Node.js, so instead the commands craft stream pipeline objects and to output content just use .pipe() to stdout. It could be more dificult to use, but more versalite and coherent with Node.js style. What do you think?
date.js seems to work if I remove the following lines. I'm not too familiar with prototypes in javascript. What's the purpose of this bit?
function inspect()
{
return result
}
Object.defineProperty(result, 'inspect', {value: inspect})
https://nodejs.org/api/util.html#util_custom_inspect_function_on_objects ;-)
Thanks!
You are welcome :-)
Ooh, the pipes would be nice. So I gather the commands would send the pipes as return values of the exposed api.
Yes, that's the idea, instead of exec commands, you would build pipeline objects that can be moved around without consume data, and when you are ready, pipe the output to a file or stdout or whatever :-) Later it could be build a more "classic" bash-like shell on top of this.