Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"cash-money" is a virtual busybox-like framework in pure javascript.

License

NotificationsYou must be signed in to change notification settings

3p3r/cash-money

Repository files navigation

"cash-money" is a virtualbusybox-like framework in pure javascript.

cash-money

usage

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 tmp

api

a 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

Stars

Watchers

Forks

Releases

No releases published

[8]ページ先頭

©2009-2025 Movatter.jp