From 7cad93a21601a71e29720092f86627fa390c1677 Mon Sep 17 00:00:00 2001 From: Nate Fischer Date: Sun, 18 Feb 2024 01:04:02 -0800 Subject: [PATCH] deprecate config.globOptions 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. --- README.md | 11 ----------- shell.js | 12 ------------ src/common.js | 3 +-- test/config.js | 15 +-------------- 4 files changed, 2 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 357e5a47..720b0c2c 100644 --- a/README.md +++ b/README.md @@ -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: @@ -882,7 +872,6 @@ Reset `shell.config` to the defaults: ```javascript { fatal: false, - globOptions: {}, maxdepth: 255, noglob: false, silent: false, diff --git a/shell.js b/shell.js index ad40740b..aa33bb6d 100644 --- a/shell.js +++ b/shell.js @@ -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() //@ @@ -165,7 +154,6 @@ exports.config = common.config; //@ ```javascript //@ { //@ fatal: false, -//@ globOptions: {}, //@ maxdepth: 255, //@ noglob: false, //@ silent: false, diff --git a/src/common.js b/src/common.js index 0ec1f813..9b258927 100644 --- a/src/common.js +++ b/src/common.js @@ -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, @@ -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) { diff --git a/test/config.js b/test/config.js index 743df356..34aa036c 100644 --- a/test/config.js +++ b/test/config.js @@ -48,7 +48,7 @@ test.cb('config.fatal = true', t => { }); // -// config.globOptions +// Default glob expansion behavior // test('Expands to directories by default', t => { @@ -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); - } -);