You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -64,6 +75,46 @@ All function (`shelljs`, `fetch`, …) are exported by library, so use:
64
75
import { … } from"nodejsscript";
65
76
```
66
77
78
+
### `xarg()`
79
+
Simplify version of `xargs` allowing passing one argument. For now only "-I" argument is allowed.
80
+
By default `{}` will be replaced, if not presented the argument is append as last one.
81
+
82
+
```js
83
+
pipe(
84
+
exec$.bind(null, "git branch --show-current"),
85
+
xarg(exec, "echo deploy --branch={}")
86
+
)();
87
+
pipe(
88
+
exec$.bind(null, "git branch --show-current"),
89
+
xarg("-I §", exec, "echo deploy --branch=§")
90
+
)();
91
+
```
92
+
93
+
### `pipe()`
94
+
Function similar to [Ramda `R.pipe`](https://ramdajs.com/docs/#pipe)). Provides functional way to combine commands/functions.
95
+
Can be used with [xarg()](#xarg). **Some functions from shelljs also allow you to combine them, see [Pipes](https://github.com/shelljs/shelljs#pipes)**.
96
+
97
+
```js
98
+
pipe(
99
+
Number,
100
+
v=>s.greenBright(v+1),
101
+
v=>`Result is: ${v}`,
102
+
echo
103
+
)(awaitquestion("Choose number:"));
104
+
105
+
```
106
+
107
+
### `cli()`
108
+
A wrapper around the [lukeed/sade: Smooth (CLI) Operator 🎶](https://github.com/lukeed/sade) package.
109
+
In addition to the origin, `cli()` supports to fill script name from script file name.
110
+
111
+
```js
112
+
cli("", true)
113
+
.version("0.1.0")
114
+
.describe("NodeJS Script cli test")
115
+
.action(echo);
116
+
```
117
+
67
118
### `fetch()`
68
119
A wrapper around the [node-fetch](https://www.npmjs.com/package/node-fetch) package.
69
120
@@ -77,22 +128,32 @@ A wrapper around the [readline](https://nodejs.org/api/readline.html) package.
77
128
```js
78
129
constbear=awaitquestion('What kind of bear is best? ')
79
130
```
131
+
132
+
### `exec$()`
133
+
A wrapper around the [exec](https://github.com/shelljs/shelljs#execcommand--options--callback) function.
134
+
Runs in silent mode and handle text to be used as variables.
135
+
136
+
```js
137
+
constbranch=exec$("git branch --show-current");
138
+
echo('Current branch is', branch);
139
+
```
140
+
80
141
### `echo()`
81
-
A `console.log()` alternative optimalozed for scripting.
142
+
A `console.log()` alternative optimalized for scripting.
82
143
83
144
```js
84
-
constbranch=exec("git branch --show-current");
145
+
constbranch=exec$("git branch --show-current");
85
146
echo('Current branch is', branch);
86
147
```
87
148
88
149
### `stdin()`
89
150
Returns the stdin as a string.
90
151
91
152
```js
92
-
constcontent=JSON.parse(awaitstdin())
153
+
constcontent=JSON.parse(awaitstdin());
93
154
```
94
155
95
-
### `chalk`
156
+
### `chalk` package
96
157
The [chalk](https://www.npmjs.com/package/chalk) package. Also as shorthand **s**.
0 commit comments