diff --git a/README.md b/README.md index 542c45bc..96d3459c 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ be escaped or unescaped. Un-escape a glob string that may contain some escaped characters. If the `windowsPathsNoEscape` option is used, then square-brace -escapes are removed, but not backslash escapes. For example, it +escapes are removed, but not backslash escapes. For example, it will turn the string `'[*]'` into `*`, but it will not turn `'\\*'` into `'*'`, because `\` is a path separator in `windowsPathsNoEscape` mode. diff --git a/src/walker.ts b/src/walker.ts index ade37d95..ba0c022c 100644 --- a/src/walker.ts +++ b/src/walker.ts @@ -201,8 +201,10 @@ export abstract class GlobUtil { this.matchEmit(e.fullpath() + mark) } else { const rel = e.relative() - const pre = this.opts.dotRelative && !rel.startsWith('..' + this.#sep) - ? '.' + this.#sep : '' + const pre = + this.opts.dotRelative && !rel.startsWith('..' + this.#sep) + ? '.' + this.#sep + : '' this.matchEmit(!rel && mark ? '.' + mark : pre + rel + mark) } } diff --git a/test/dot-relative.ts b/test/dot-relative.ts index 62c0c168..5a27027a 100644 --- a/test/dot-relative.ts +++ b/test/dot-relative.ts @@ -1,7 +1,7 @@ import t from 'tap' import { Glob } from '../' import { bashResults } from './bash-results' -import {resolve, sep} from 'path' +import { resolve, sep } from 'path' const pattern = 'a/b/**' process.chdir(__dirname + '/fixtures') @@ -39,19 +39,22 @@ for (const mark of marks) { } }) - t.test('does not prefix with ./ unless dotRelative is true', async t => { - const g = new Glob(pattern, {}) - const results = await g.walk() + t.test( + 'does not prefix with ./ unless dotRelative is true', + async t => { + const g = new Glob(pattern, {}) + const results = await g.walk() - t.equal( - results.length, - bashResults[pattern].length, - 'must match all files' - ) - for (const m of results) { - t.ok(mark && m === '.' + sep || !m.startsWith('.' + sep)) + t.equal( + results.length, + bashResults[pattern].length, + 'must match all files' + ) + for (const m of results) { + t.ok((mark && m === '.' + sep) || !m.startsWith('.' + sep)) + } } - }) + ) }) } diff --git a/test/escape.ts b/test/escape.ts index b9a56342..5e1ac085 100644 --- a/test/escape.ts +++ b/test/escape.ts @@ -6,11 +6,16 @@ for (const pattern of Object.keys(bashResults)) { t.notOk(hasMagic(escape(pattern)), `escape(${pattern})`) const pp = escape(pattern) const pw = escape(pattern, { - windowsPathsNoEscape: true + windowsPathsNoEscape: true, }) - t.notOk(hasMagic(pp, { platform: 'linux' }), 'no magic after posix escape') - t.notOk(hasMagic(pw, { platform: 'win32', windowsPathsNoEscape: true }), - 'no magic after windows escape') + t.notOk( + hasMagic(pp, { platform: 'linux' }), + 'no magic after posix escape' + ) + t.notOk( + hasMagic(pw, { platform: 'win32', windowsPathsNoEscape: true }), + 'no magic after windows escape' + ) const up = unescape(pp) const uw = unescape(pw, { windowsPathsNoEscape: true }) t.equal(up, pattern, 'unescaped posix pattern returned') diff --git a/test/url-cwd.ts b/test/url-cwd.ts index 1733dabe..e3c584b2 100644 --- a/test/url-cwd.ts +++ b/test/url-cwd.ts @@ -1,11 +1,11 @@ import t from 'tap' -import {pathToFileURL} from 'url' -import {Glob} from '../' +import { pathToFileURL } from 'url' +import { Glob } from '../' t.test('can use file url as cwd option', t => { const fileURL = pathToFileURL(process.cwd()) const fileURLString = String(fileURL) - const ps = new Glob('.', { cwd: process.cwd()}) + const ps = new Glob('.', { cwd: process.cwd() }) const pu = new Glob('.', { cwd: fileURL }) const pus = new Glob('.', { cwd: fileURLString }) t.equal(ps.cwd, process.cwd())