raine / ramda-cli

:ram: A CLI tool for processing data with functional pipelines
ISC License
573 stars 12 forks source link

doesn't seem to be working on windows #5

Closed jon49 closed 9 years ago

jon49 commented 9 years ago

I'm not fully familiar with how node/npm does console apps and I don't have much time for more debugging (I might have time later). But this is a start.

Not sure what exactly is going on but when I run this command (the others give errors too, but one thing at a time :-) ):

ramda --no-stdin 'always "hello world"' 'add __, \!'

I get this output

ramda : Error: Cannot find module 'C:\Users\1198462\.config\ramda-cli'
At line:2 char:1
+ ramda --no-stdin 'always "hello world"' 'add __, \!'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Error: Cannot f...nfig\ramda-cli':String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

when I intercept the call in C:\Program Files (x86)\nodejs\node_modules\ramda-cli\bin with console.log(process.argv, process.stdin, process.stdout, process.stderr):

[ 'C:\\Program Files (x86)\\nodejs\\\\node.exe',
  'C:\\Program Files (x86)\\nodejs\\node_modules\\ramda-cli\\bin\\ramda',
  '--no-stdin',
  'always hello',
  'world',
  'add __, \\!' ] { _connecting: false,
  _hadError: false,
  _handle: 
   { fd: undefined,
     writeQueueSize: 0,
     owner: [Circular],
     onread: [Function: onread],
     reading: false },
  _parent: null,
  _host: null,
  _readableState: 
   { objectMode: false,
     highWaterMark: 0,
     buffer: [],
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: false,
     endEmitted: false,
     reading: false,
     sync: false,
     needReadable: true,
     emittedReadable: false,
     readableListening: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: true,
  domain: null,
  _events: 
   { end: { [Function: g] listener: [Function: onend] },
     finish: [Function: onSocketFinish],
     _socketEnd: [Function: onSocketEnd],
     pause: [Function] },
  _maxListeners: undefined,
  _writableState: 
   { objectMode: false,
     highWaterMark: 0,
     needDrain: false,
     ending: false,
     ended: false,
     finished: false,
     decodeStrings: false,
     defaultEncoding: 'utf8',
     length: 0,
     writing: false,
     corked: 0,
     sync: true,
     bufferProcessing: false,
     onwrite: [Function],
     writecb: null,
     writelen: 0,
     bufferedRequest: null,
     lastBufferedRequest: null,
     pendingcb: 0,
     prefinished: false,
     errorEmitted: false },
  writable: false,
  allowHalfOpen: false,
  destroyed: false,
  bytesRead: 0,
  _bytesDispatched: 0,
  _writev: null,
  _pendingData: null,
  _pendingEncoding: '',
  isRaw: false,
  isTTY: true,
  fd: 0 } { _connecting: false,
  _hadError: false,
  _handle: 
   { fd: undefined,
     writeQueueSize: 0,
     owner: [Circular],
     onread: [Function: onread] },
  _parent: null,
  _host: null,
  _readableState: 
   { objectMode: false,
     highWaterMark: 16384,
     buffer: [],
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: false,
     endEmitted: false,
     reading: false,
     sync: true,
     needReadable: false,
     emittedReadable: false,
     readableListening: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: false,
  domain: null,
  _events: 
   { end: { [Function: g] listener: [Function: onend] },
     finish: [Function: onSocketFinish],
     _socketEnd: [Function: onSocketEnd] },
  _maxListeners: undefined,
  _writableState: 
   { objectMode: false,
     highWaterMark: 16384,
     needDrain: false,
     ending: false,
     ended: false,
     finished: false,
     decodeStrings: false,
     defaultEncoding: 'utf8',
     length: 0,
     writing: false,
     corked: 0,
     sync: true,
     bufferProcessing: false,
     onwrite: [Function],
     writecb: null,
     writelen: 0,
     bufferedRequest: null,
     lastBufferedRequest: null,
     pendingcb: 0,
     prefinished: false,
     errorEmitted: false },
  writable: true,
  allowHalfOpen: false,
  destroyed: false,
  bytesRead: 0,
  _bytesDispatched: 0,
  _writev: null,
  _pendingData: null,
  _pendingEncoding: '',
  read: null,
  _type: 'pipe',
  fd: 1,
  _isStdio: true,
  destroySoon: [Function],
  destroy: [Function] } { _connecting: false,
  _hadError: false,
  _handle: 
   { fd: undefined,
     writeQueueSize: 0,
     owner: [Circular],
     onread: [Function: onread] },
  _parent: null,
  _host: null,
  _readableState: 
   { objectMode: false,
     highWaterMark: 16384,
     buffer: [],
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: false,
     endEmitted: false,
     reading: false,
     sync: true,
     needReadable: false,
     emittedReadable: false,
     readableListening: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: false,
  domain: null,
  _events: 
   { end: { [Function: g] listener: [Function: onend] },
     finish: [Function: onSocketFinish],
     _socketEnd: [Function: onSocketEnd] },
  _maxListeners: undefined,
  _writableState: 
   { objectMode: false,
     highWaterMark: 16384,
     needDrain: false,
     ending: false,
     ended: false,
     finished: false,
     decodeStrings: false,
     defaultEncoding: 'utf8',
     length: 0,
     writing: false,
     corked: 0,
     sync: true,
     bufferProcessing: false,
     onwrite: [Function],
     writecb: null,
     writelen: 0,
     bufferedRequest: null,
     lastBufferedRequest: null,
     pendingcb: 0,
     prefinished: false,
     errorEmitted: false },
  writable: true,
  allowHalfOpen: false,
  destroyed: false,
  bytesRead: 0,
  _bytesDispatched: 0,
  _writev: null,
  _pendingData: null,
  _pendingEncoding: '',
  read: null,
  _type: 'pipe',
  fd: 2,
  _isStdio: true,
  destroySoon: [Function],
  destroy: [Function] }
raine commented 9 years ago

Looks like Windows might have different error code in case a module is not found.

Can you try creating an empty file at C:\Users\1198462\.config\ramda-cli.js?

jon49 commented 9 years ago

Now I get the following when adding the empty file.

ramda : Error: evalmachine.<anonymous>:1
At line:2 char:1
+ ramda --no-stdin 'always "hello world"' 'add __, \!'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Error: evalmachine.<anonymous>:1:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

pipe(always(hello), world, add(__, '!'));
            ^
hello is not defined
jon49 commented 9 years ago

When I switch the quotes like so:

ramda --no-stdin "always 'hello world'"

it outputs:

"hello world"

So, that seemed to work. Not sure why it is pointing to that directory though.

raine commented 9 years ago

It's trying to read a config from that place.

Can you add these console.log lines to the compiled ramda-cli/lib/main.js that is somewhere in your system, and see what it logs when you remove C:\Users\1198462\.config\ramda-cli.js

 53   makeSandbox = function(){
 54     var userConfig, e, ref$;
 55     try {
 56       userConfig = require(config.BASE_PATH);
 57     } catch (e$) {
 58       e = e$;
 59       console.log(e.code)
 60       console.log(e.message)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
vendethiel commented 9 years ago

You have to use "" for CLI arguments on windows.

jon49 commented 9 years ago
code: MODULE_NOT_FOUND
message: Cannot find module 'C:\Users\1198462\.config\ramda-cli'
raine commented 9 years ago

Makes sense. I published a new version with a fix.

raine commented 9 years ago

And thank you @jon49 and @vendethiel

jon49 commented 9 years ago

That did it. Thanks. Great tool!