Skip to content

Commit bf2a671

Browse files
committed
📝 config
1 parent b7a66be commit bf2a671

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,17 @@ const content= JSON.parse(await stdin());
152152
### `config`
153153
Read/write global configuration.
154154

155-
- `verbose`: Will print each executed command to the screen.
156-
- `fatal`: If true the script will die on errors.
157-
- `noglob`: Disable filename expansion (globbing)
155+
- `silent` [`false`]: Suppresses all command output if `true`, except for `echo()` call.
156+
- `verbose` [`false`]: Will print each executed command to the screen.
157+
- `fatal` [`false`]: If `true`, the script will throw a JavaScript error when any `shell.js` command encounters an error. This is analogous to Bash's `set -e`.
158+
- `noglob` [`false`]: Disable filename expansion (globbing)
159+
- `globOptions` [`{}`]: Options for [`glob.sync()`](https://github.com/isaacs/node-glob/tree/af57da21c7722bb6edb687ccd4ad3b99d3e7a333#options).
158160

159161
```js
160162
const { verbose, fatal, noglob }= config;
163+
config.silent= true;
164+
const config.assign({ verbose: true, silent: false });
165+
161166
```
162167

163168
### `chalk` package

index.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,39 @@ export function exec$(command, options= {}){
4848

4949
const _config= shelljs.config;
5050
export const config= {
51-
/** Will print each executed command to the screen.
52-
* @default false
53-
*/
51+
/**
52+
* Suppresses all command output if `true`, except for `echo()` call.
53+
* @default false
54+
* */
55+
get silent(){ return _config.silent; },
56+
set silent(v){ _config.silent= v; },
57+
/**
58+
* Will print each executed command to the screen.
59+
* @default false
60+
* */
5461
get verbose(){ return _config.verbose; },
55-
set verbose(v){ return (_config.verbose = v); },
56-
/** If true the script will die on errors. Default is false. */
62+
set verbose(v){ return (_config.verbose= v); },
63+
/**
64+
* If `true`, the script will throw a JavaScript error when any `shell.js` command encounters an error. This is analogous to Bash's `set -e`.
65+
* @default false
66+
* */
5767
get fatal(){ return _config.fatal; },
58-
set fatal(v){ return (_config.fatal = v); },
59-
/** Disable filename expansion (globbing) */
68+
set fatal(v){ return (_config.fatal= v); },
69+
/**
70+
* Disable filename expansion (globbing)
71+
* @default false
72+
* */
6073
get noglob(){ return _config.noglob; },
61-
set noglob(v){ return (_config.noglob = v); },
74+
set noglob(v){ return (_config.noglob= v); },
75+
/**
76+
* Options for [`glob.sync()`](https://github.com/isaacs/node-glob/tree/af57da21c7722bb6edb687ccd4ad3b99d3e7a333#options).
77+
* @default {}
78+
* */
79+
get globOptions(){ return _config.globOptions; },
80+
set globOptions(v){ return (_config.globOptions= v); },
81+
6282
/** Set multiple options with one command.
63-
* @param {...Record<"verbose"|"fatal"|"noglob",boolean>} c
83+
* @param {...Record<"verbose"|"fatal"|"noglob"|"silent",boolean>} c
6484
* */
6585
assign(...c){ return Object.assign(this, ...c); }
6686
};

0 commit comments

Comments
 (0)