raine / ramda-cli

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

Per project library inclusion #10

Closed JAForbes closed 7 years ago

JAForbes commented 8 years ago

This library is incredible. I'm wondering if its possible to configure included libraries on a per project basis. I'd like to include Sanctuary but I need these commands to run in a CI environment. I could drop stuff into the HOME directory but it'd be a lot nicer for ramda cli to piggy back of modules that already exist in a project.

Would you be open to a PR that enables piggy backing on ./node_modules/.bin in the cwd? I'd be fine if it was guarded by a flag. Maybe something like:

ramda --include sanctuary

I'd like the functions to be injected as globals but I'd be ok to namespace them if that's better, something like?

ramda --include T=data.task

What do you think?

raine commented 7 years ago

I've added -I, --import and made require() (which it uses) to look for modules in $PWD/node_modules. This should make ramda-cli work as a dependency of a project and in npm scripts so that other modules can be used with it.

$ npm run test
> testdir@1.0.0 test /testdir
> date +%s | ramda -r --import m=moment "m.unix"

"2017-03-10T23:34:00.000Z"

Also, while at it, I made Promise values unwrap. Might be of use when using async modules with ramda-cli.

https://github.com/raine/ramda-cli#promises