https://github.com/bulkan/co-sh
Using ES6 Proxies & Generators to run shell commands
https://github.com/bulkan/co-sh
es6 generators javascript proxies proxy
Last synced: 4 months ago
JSON representation
Using ES6 Proxies & Generators to run shell commands
- Host: GitHub
- URL: https://github.com/bulkan/co-sh
- Owner: bulkan
- License: mit
- Created: 2014-06-05T00:56:11.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T03:53:57.000Z (about 8 years ago)
- Last Synced: 2025-08-14T02:23:34.952Z (10 months ago)
- Topics: es6, generators, javascript, proxies, proxy
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 24
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
sh
==
Call any shell command like a function using ES 6 Proxies & Generators.
Use `node v5.0.x` with `--harmony-proxies` flag, along with
* [co](https://github.com/visionmedia/co)
* [thunkify](https://github.com/visionmedia/node-thunkify)
* [co-read](https://github.com/juliangruber/co-read)
## Usage
```javascript
var co = require('co');
var read = require('co-read');
var sh = require('co-sh');
co(function *(){
var ls = yield sh.ls();
var buf;
while (buf = yield read(ls.stdout)) {
console.log(buf.toString());
}
try {
yield sh.nonexistingcmd();
} catch(e){
console.log(e);
}
})();
```
Assuming the above code is in a file called `test.js` run it using;
node --harmony-proxies test.js
See the examples folder for more
## License
MIT