Skip to content

Commit

Permalink
deprecate config.globOptions
Browse files Browse the repository at this point in the history
This removes support for configuring `config.globOptions`. Exposing this
variable makes it difficult to change (or upgrade) our glob library.
It's best to consider our choice of glob library to be an implementation
detail.

As far as I know, this is not a commonly used option:
https://github.com/shelljs/shelljs/issues?q=globOptions currently shows
no GitHub issues of users using this option, and there was never really
a motivation for why this needed to be exposed (#400 exposed the option
just because we could, not because we should).

This is one step toward supporting Issue #828.
  • Loading branch information
nfischer committed Feb 18, 2024
1 parent 2ff87ef commit 7cad93a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 39 deletions.
11 changes: 0 additions & 11 deletions README.md
Expand Up @@ -854,16 +854,6 @@ rm -rf foo.txt bar.txt
exec echo hello
```

### config.globOptions

Example:

```javascript
config.globOptions = {nodir: true};
```

Use this value for calls to `glob.sync()` instead of the default options.

### config.reset()

Example:
Expand All @@ -882,7 +872,6 @@ Reset `shell.config` to the defaults:
```javascript
{
fatal: false,
globOptions: {},
maxdepth: 255,
noglob: false,
silent: false,
Expand Down
12 changes: 0 additions & 12 deletions shell.js
Expand Up @@ -135,17 +135,6 @@ exports.config = common.config;
//@ exec echo hello
//@ ```

//@
//@ ### config.globOptions
//@
//@ Example:
//@
//@ ```javascript
//@ config.globOptions = {nodir: true};
//@ ```
//@
//@ Use this value for calls to `glob.sync()` instead of the default options.

//@
//@ ### config.reset()
//@
Expand All @@ -165,7 +154,6 @@ exports.config = common.config;
//@ ```javascript
//@ {
//@ fatal: false,
//@ globOptions: {},
//@ maxdepth: 255,
//@ noglob: false,
//@ silent: false,
Expand Down
3 changes: 1 addition & 2 deletions src/common.js
Expand Up @@ -19,7 +19,6 @@ var isElectron = Boolean(process.versions.electron);
// Module globals (assume no execPath by default)
var DEFAULT_CONFIG = {
fatal: false,
globOptions: {},
maxdepth: 255,
noglob: false,
silent: false,
Expand Down Expand Up @@ -263,7 +262,7 @@ function expand(list) {
} else {
var ret;
try {
ret = glob.sync(listEl, config.globOptions);
ret = glob.sync(listEl, {});
// if nothing matched, interpret the string literally
ret = ret.length > 0 ? ret : [listEl];
} catch (e) {
Expand Down
15 changes: 1 addition & 14 deletions test/config.js
Expand Up @@ -48,7 +48,7 @@ test.cb('config.fatal = true', t => {
});

//
// config.globOptions
// Default glob expansion behavior
//

test('Expands to directories by default', t => {
Expand All @@ -60,16 +60,3 @@ test('Expands to directories by default', t => {
t.truthy(result.indexOf('test/resources/head') > -1);
t.truthy(result.indexOf('test/resources/external') > -1);
});

test(
'Check to make sure options get passed through (nodir is an example)',
t => {
shell.config.globOptions = { nodir: true };
const result = common.expand(['test/resources/*a*']);
t.is(result.length, 2);
t.truthy(result.indexOf('test/resources/a.txt') > -1);
t.truthy(result.indexOf('test/resources/badlink') > -1);
t.truthy(result.indexOf('test/resources/cat') < 0);
t.truthy(result.indexOf('test/resources/external') < 0);
}
);

0 comments on commit 7cad93a

Please sign in to comment.