Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate config.globOptions #1152

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -854,15 +854,23 @@ rm -rf foo.txt bar.txt
exec echo hello
```

### config.globOptions
### config.globOptions (deprecated)

**Deprecated**: we recommend that you do not edit `config.globOptions`.
Support for this configuration option may be changed or removed in a future
ShellJS release.

Example:

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

Use this value for calls to `glob.sync()` instead of the default options.
`config.globOptions` changes how ShellJS expands glob (wildcard)
expressions. See
[node-glob](https://github.com/isaacs/node-glob?tab=readme-ov-file#options)
for available options. Be aware that modifying `config.globOptions` **may
break ShellJS functionality.**

### config.reset()

Expand Down
12 changes: 10 additions & 2 deletions shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,23 @@ exports.config = common.config;
//@ ```

//@
//@ ### config.globOptions
//@ ### config.globOptions (deprecated)
//@
//@ **Deprecated**: we recommend that you do not edit `config.globOptions`.
//@ Support for this configuration option may be changed or removed in a future
//@ ShellJS release.
//@
//@ Example:
//@
//@ ```javascript
//@ config.globOptions = {nodir: true};
//@ ```
//@
//@ Use this value for calls to `glob.sync()` instead of the default options.
//@ `config.globOptions` changes how ShellJS expands glob (wildcard)
//@ expressions. See
//@ [node-glob](https://github.com/isaacs/node-glob?tab=readme-ov-file#options)
//@ for available options. Be aware that modifying `config.globOptions` **may
//@ break ShellJS functionality.**

//@
//@ ### config.reset()
Expand Down
8 changes: 7 additions & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ function parseOptions(opt, map, errorOptions) {
}
exports.parseOptions = parseOptions;

function globOptions() {
// TODO(nfischer): if this changes glob implementation in the future, convert
// options back to node-glob's option format for backward compatibility.
return config.globOptions;
}

// Expands wildcards with matching (ie. existing) file names.
// For example:
// expand(['file*.js']) = ['file1.js', 'file2.js', ...]
Expand All @@ -263,7 +269,7 @@ function expand(list) {
} else {
var ret;
try {
ret = glob.sync(listEl, config.globOptions);
ret = glob.sync(listEl, globOptions());
// if nothing matched, interpret the string literally
ret = ret.length > 0 ? ret : [listEl];
} catch (e) {
Expand Down