- Notifications
You must be signed in to change notification settings - Fork0
"cash-money" is a virtual busybox-like framework in pure javascript.
License
3p3r/cash-money
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
"cash-money" is a virtualbusybox-like framework in pure javascript.
install:
npm i react-ode-cash-money
sample:
const{ cash, fs}=require("react-ode-cash-money");// this all happens in-memory!(async()=>{console.log(awaitcash("echo 'hello world'"));fs.writeFileSync("sample.txt","hello file content","utf8");awaitcash("touch random.log");console.log(awaitcash("cat sample.txt"));console.log(awaitcash("ls -lah"));})();
output:
hello worldhello file contenttotal 18drw-rw-rw- 1 1000 1000 0 May 27 13:22.drw-rw-rw- 1 1000 1000 0 May 27 13:22 ..-rw-rw-rw- 1 1000 1000 0 May 27 13:22 random.log-rw-rw-rw- 1 1000 1000 18 May 27 13:22 sample.txtdrwxrwxrwx 1 1000 1000 0 May 27 13:22 tmpa singleuse api is exposed where you can define "programs" for the shell.exec() is program's entrypoint andsetup() is like itsgetopts.
"cash-money" modifies "cash" to accept asyncexec()s but you still need to make sureexec()s are executed serially asynchronously.
meaning that you cannot call cash commands in the middle of each other. there is no threading or process management.
do a waterfallawait cash(<thing 1>); await cash(<thing 2>); and you are good with no race conditions.
const{console:logger, cash, use}=require("react-ode-cash-money");// this works if you call before 1st executionuse({// program's binary namename:"sample",// help when executed as "help <command>"help:"sample help",// program's entry pointexec:asyncfunction(argv){// application logic goes hereif(argv.version){logger.log("Sample 1.0.0");// or import console from cash-moneyreturn0;}},// program's command line parser setupsetup:function(vorpal,interfacer,preparser){vorpal.command("sample").parse(preparser).option("-v, --version","show version").action(function(args,callback){// this call glues vorpal to cash basicallyreturninterfacer.call(this,args,callback);});},});// this is how you use the new command:(async()=>{console.log(awaitcash(`sample --version`));console.log(awaitcash(`help sample`));})();
About
"cash-money" is a virtual busybox-like framework in pure javascript.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Uh oh!
There was an error while loading.Please reload this page.
