Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebastienros/pipejs
Command Line JavaScript interpreter
https://github.com/sebastienros/pipejs
Last synced: 3 months ago
JSON representation
Command Line JavaScript interpreter
- Host: GitHub
- URL: https://github.com/sebastienros/pipejs
- Owner: sebastienros
- License: mit
- Created: 2015-05-26T04:11:19.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-02-27T19:59:02.000Z (11 months ago)
- Last Synced: 2024-05-01T20:25:48.758Z (9 months ago)
- Language: C#
- Size: 11.7 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PipeJs
PipeJs is a JavaScript Command Line Interpreter for .NET. It means you can execute custom JavaScript from the command line, by passing JavaScript statements and script files as arguments.## Quick Start
PipeJs is used by calling `pipejs.exe` from the command line. Here are some typical ways to use it:
### Returning a JavaScript primitive value
Any returned primitive value is displayed using `.toString()` on it.```
pipejs return Math.PI * 2
```
`6.28318530717959`### Returning a JavaScript complex object
Complex objects are serialized into JSON.```
pipejs var o = {}; o.Color = 'Red'; return o;
```
`{"Color":"Red"}`### Piping arguments to a script
Any value can be passed to `pipejs` as the `this` argument.
```
echo { "foo" : "bar" } | pipejs return this.foo;
```
`bar`### Outputing custom text to the console
The `console` object is available.
```
echo 9 | pipejs "if(this > 5) console.log(this); else console.warning(this);"
```### Using an external script file
PipeJs can execute a script from a specific file.
```
pipejs @myScript.js
```### Piping outputs to inputs
The output of a pipejs script can be used as the input of another one.
```
echo 9 | pipejs return this * 2 | pipejs return this - 10
```
`8`