diff options
Diffstat (limited to 'std/path')
-rw-r--r-- | std/path/_globrex.ts | 9 | ||||
-rw-r--r-- | std/path/_globrex_test.ts | 258 | ||||
-rw-r--r-- | std/path/_util.ts | 10 | ||||
-rw-r--r-- | std/path/basename_test.ts | 4 | ||||
-rw-r--r-- | std/path/common_test.ts | 6 | ||||
-rw-r--r-- | std/path/dirname_test.ts | 6 | ||||
-rw-r--r-- | std/path/glob.ts | 11 | ||||
-rw-r--r-- | std/path/glob_test.ts | 24 | ||||
-rw-r--r-- | std/path/posix.ts | 4 | ||||
-rw-r--r-- | std/path/win32.ts | 6 |
10 files changed, 169 insertions, 169 deletions
diff --git a/std/path/_globrex.ts b/std/path/_globrex.ts index 6ad297d86..0cc5399fa 100644 --- a/std/path/_globrex.ts +++ b/std/path/_globrex.ts @@ -57,7 +57,7 @@ export function globrex( strict = false, filepath = false, flags = "", - }: GlobrexOptions = {} + }: GlobrexOptions = {}, ): GlobrexResult { const sepPattern = new RegExp(`^${SEP}${strict ? "" : "+"}$`); let regex = ""; @@ -82,7 +82,7 @@ export function globrex( // Helper function to build string and segments function add( str: string, - options: AddOptions = { split: false, last: false, only: "" } + options: AddOptions = { split: false, last: false, only: "" }, ): void { const { split, last, only } = options; if (only !== "path") regex += str; @@ -279,8 +279,7 @@ export function globrex( add(".*"); } else { // globstar is enabled, so determine if this is a globstar segment - const isGlobstar = - starCount > 1 && // multiple "*"'s + const isGlobstar = starCount > 1 && // multiple "*"'s // from the start of the segment [SEP_RAW, "/", undefined].includes(prevChar) && // to the end of the segment @@ -320,7 +319,7 @@ export function globrex( segments: pathSegments, globstar: new RegExp( !flags.includes("g") ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, - flags + flags, ), }; } diff --git a/std/path/_globrex_test.ts b/std/path/_globrex_test.ts index 67a58cc64..19eabc983 100644 --- a/std/path/_globrex_test.ts +++ b/std/path/_globrex_test.ts @@ -11,7 +11,7 @@ function match( glob: string, strUnix: string, strWin?: string | object, - opts: GlobrexOptions = {} + opts: GlobrexOptions = {}, ): boolean { if (typeof strWin === "object") { opts = strWin; @@ -48,19 +48,19 @@ Deno.test({ t.equal( match("u*orn", "unicorn", { flags: "g" }), true, - "match the middle" + "match the middle", ); t.equal(match("ico", "unicorn"), false, "do not match without g"); t.equal( match("ico", "unicorn", { flags: "g" }), true, - 'match anywhere with RegExp "g"' + 'match anywhere with RegExp "g"', ); t.equal(match("u*nicorn", "unicorn"), true, "match zero characters"); t.equal( match("u*nicorn", "unicorn", { flags: "g" }), true, - "match zero characters" + "match zero characters", ); }, }); @@ -73,34 +73,34 @@ Deno.test({ globstar: false, }), true, - "complex match" + "complex match", ); t.equal( match("*.min.*", "http://example.com/jquery.min.js", { globstar: false }), true, - "complex match" + "complex match", ); t.equal( match("*/js/*.js", "http://example.com/js/jquery.min.js", { globstar: false, }), true, - "complex match" + "complex match", ); t.equal( match("*.min.*", "http://example.com/jquery.min.js", { flags: "g" }), true, - "complex match global" + "complex match global", ); t.equal( match("*.min.js", "http://example.com/jquery.min.js", { flags: "g" }), true, - "complex match global" + "complex match global", ); t.equal( match("*/js/*.js", "http://example.com/js/jquery.min.js", { flags: "g" }), true, - "complex match global" + "complex match global", ); const str = "\\/$^+?.()=!|{},[].*"; @@ -108,70 +108,70 @@ Deno.test({ t.equal( match(str, str, { flags: "g" }), true, - "battle test complex string - strict" + "battle test complex string - strict", ); t.equal( match(".min.", "http://example.com/jquery.min.js"), false, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("*.min.*", "http://example.com/jquery.min.js"), true, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match(".min.", "http://example.com/jquery.min.js", { flags: "g" }), true, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("http:", "http://example.com/jquery.min.js"), false, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("http:*", "http://example.com/jquery.min.js"), true, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("http:", "http://example.com/jquery.min.js", { flags: "g" }), true, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("min.js", "http://example.com/jquery.min.js"), false, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("*.min.js", "http://example.com/jquery.min.js"), true, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("min.js", "http://example.com/jquery.min.js", { flags: "g" }), true, - 'matches without/with using RegExp "g"' + 'matches without/with using RegExp "g"', ); t.equal( match("min", "http://example.com/jquery.min.js", { flags: "g" }), true, - 'match anywhere (globally) using RegExp "g"' + 'match anywhere (globally) using RegExp "g"', ); t.equal( match("/js/", "http://example.com/js/jquery.min.js", { flags: "g" }), true, - 'match anywhere (globally) using RegExp "g"' + 'match anywhere (globally) using RegExp "g"', ); t.equal(match("/js*jq*.js", "http://example.com/js/jquery.min.js"), false); t.equal( match("/js*jq*.js", "http://example.com/js/jquery.min.js", { flags: "g", }), - true + true, ); }, }); @@ -186,28 +186,28 @@ Deno.test({ const tester = (globstar: boolean): void => { t.equal( match("f?o", "foo", { extended: true, globstar, flags: "g" }), - true + true, ); t.equal( match("f?o", "fooo", { extended: true, globstar, flags: "g" }), - true + true, ); t.equal( match("f?o?", "fooo", { extended: true, globstar, flags: "g" }), - true + true, ); t.equal( match("?fo", "fooo", { extended: true, globstar, flags: "g" }), - false + false, ); t.equal( match("f?oo", "foo", { extended: true, globstar, flags: "g" }), - false + false, ); t.equal( match("foo?", "foo", { extended: true, globstar, flags: "g" }), - false + false, ); }; @@ -230,15 +230,15 @@ Deno.test({ const tester = (globstar: boolean): void => { t.equal( match("fo[oz]", "foo", { extended: true, globstar, flags: "g" }), - true + true, ); t.equal( match("fo[oz]", "foz", { extended: true, globstar, flags: "g" }), - true + true, ); t.equal( match("fo[oz]", "fog", { extended: true, globstar, flags: "g" }), - false + false, ); }; @@ -252,55 +252,55 @@ Deno.test({ fn(): void { t.equal( match("[[:alnum:]]/bar.txt", "a/bar.txt", { extended: true }), - true + true, ); t.equal( match("@([[:alnum:]abc]|11)/bar.txt", "11/bar.txt", { extended: true }), - true + true, ); t.equal( match("@([[:alnum:]abc]|11)/bar.txt", "a/bar.txt", { extended: true }), - true + true, ); t.equal( match("@([[:alnum:]abc]|11)/bar.txt", "b/bar.txt", { extended: true }), - true + true, ); t.equal( match("@([[:alnum:]abc]|11)/bar.txt", "c/bar.txt", { extended: true }), - true + true, ); t.equal( match("@([[:alnum:]abc]|11)/bar.txt", "abc/bar.txt", { extended: true }), - false + false, ); t.equal( match("@([[:alnum:]abc]|11)/bar.txt", "3/bar.txt", { extended: true }), - true + true, ); t.equal( match("[[:digit:]]/bar.txt", "1/bar.txt", { extended: true }), - true + true, ); t.equal( match("[[:digit:]b]/bar.txt", "b/bar.txt", { extended: true }), - true + true, ); t.equal( match("[![:digit:]b]/bar.txt", "a/bar.txt", { extended: true }), - true + true, ); t.equal( match("[[:alnum:]]/bar.txt", "!/bar.txt", { extended: true }), - false + false, ); t.equal( match("[[:digit:]]/bar.txt", "a/bar.txt", { extended: true }), - false + false, ); t.equal( match("[[:digit:]b]/bar.txt", "a/bar.txt", { extended: true }), - false + false, ); }, }); @@ -320,7 +320,7 @@ Deno.test({ globstar, flag: "g", }), - true + true, ); t.equal( match("foo{bar,baaz}", "foobar", { @@ -328,7 +328,7 @@ Deno.test({ globstar, flag: "g", }), - true + true, ); t.equal( match("foo{bar,baaz}", "foobuzz", { @@ -336,7 +336,7 @@ Deno.test({ globstar, flag: "g", }), - false + false, ); t.equal( match("foo{bar,b*z}", "foobuzz", { @@ -344,7 +344,7 @@ Deno.test({ globstar, flag: "g", }), - true + true, ); }; @@ -360,41 +360,41 @@ Deno.test({ match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://foo.baaz.com/jquery.min.js", - { extended: true } + { extended: true }, ), - true + true, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://moz.buzz.com/index.html", - { extended: true } + { extended: true }, ), - true + true, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://moz.buzz.com/index.htm", - { extended: true } + { extended: true }, ), - false + false, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://moz.bar.com/index.html", - { extended: true } + { extended: true }, ), - false + false, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://flozz.buzz.com/index.html", - { extended: true } + { extended: true }, ), - false + false, ); const tester = (globstar: boolean): void => { @@ -402,41 +402,41 @@ Deno.test({ match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://foo.baaz.com/jquery.min.js", - { extended: true, globstar, flags: "g" } + { extended: true, globstar, flags: "g" }, ), - true + true, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://moz.buzz.com/index.html", - { extended: true, globstar, flags: "g" } + { extended: true, globstar, flags: "g" }, ), - true + true, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://moz.buzz.com/index.htm", - { extended: true, globstar, flags: "g" } + { extended: true, globstar, flags: "g" }, ), - false + false, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://moz.bar.com/index.html", - { extended: true, globstar, flags: "g" } + { extended: true, globstar, flags: "g" }, ), - false + false, ); t.equal( match( "http://?o[oz].b*z.com/{*.js,*.html}", "http://flozz.buzz.com/index.html", - { extended: true, globstar, flags: "g" } + { extended: true, globstar, flags: "g" }, ), - false + false, ); }; @@ -453,17 +453,17 @@ Deno.test({ match( "http://foo.com/**/{*.js,*.html}", "http://foo.com/bar/jquery.min.js", - { extended: true, globstar, flags: "g" } + { extended: true, globstar, flags: "g" }, ), - true + true, ); t.equal( match( "http://foo.com/**/{*.js,*.html}", "http://foo.com/bar/baz/jquery.min.js", - { extended: true, globstar, flags: "g" } + { extended: true, globstar, flags: "g" }, ), - true + true, ); t.equal( match("http://foo.com/**", "http://foo.com/bar/baz/jquery.min.js", { @@ -471,7 +471,7 @@ Deno.test({ globstar, flags: "g", }), - true + true, ); }; @@ -488,7 +488,7 @@ Deno.test({ t.equal(match(testExtStr, testExtStr, { extended: true }), true); t.equal( match(testExtStr, testExtStr, { extended: true, globstar, flags: "g" }), - true + true, ); }; @@ -506,37 +506,37 @@ Deno.test({ t.equal(match("/foo/**", "/foo/bar/baz.txt", { globstar: true }), true); t.equal( match("/foo/*/*.txt", "/foo/bar/baz.txt", { globstar: true }), - true + true, ); t.equal( match("/foo/**/*.txt", "/foo/bar/baz.txt", { globstar: true }), - true + true, ); t.equal( match("/foo/**/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }), - true + true, ); t.equal(match("/foo/**/bar.txt", "/foo/bar.txt", { globstar: true }), true); t.equal( match("/foo/**/**/bar.txt", "/foo/bar.txt", { globstar: true }), - true + true, ); t.equal( match("/foo/**/*/baz.txt", "/foo/bar/baz.txt", { globstar: true }), - true + true, ); t.equal(match("/foo/**/*.txt", "/foo/bar.txt", { globstar: true }), true); t.equal( match("/foo/**/**/*.txt", "/foo/bar.txt", { globstar: true }), - true + true, ); t.equal( match("/foo/**/*/*.txt", "/foo/bar/baz.txt", { globstar: true }), - true + true, ); t.equal( match("**/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }), - true + true, ); t.equal(match("**/foo.txt", "foo.txt", { globstar: true }), true); t.equal(match("**/*.txt", "foo.txt", { globstar: true }), true); @@ -544,29 +544,29 @@ Deno.test({ t.equal(match("/foo/*.txt", "/foo/bar/baz.txt", { globstar: true }), false); t.equal( match("/foo/*/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }), - false + false, ); t.equal(match("/foo/*/bar.txt", "/foo/bar.txt", { globstar: true }), false); t.equal( match("/foo/*/*/baz.txt", "/foo/bar/baz.txt", { globstar: true }), - false + false, ); t.equal( match("/foo/**.txt", "/foo/bar/baz/qux.txt", { globstar: true }), - false + false, ); t.equal( match("/foo/bar**/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }), - false + false, ); t.equal(match("/foo/bar**", "/foo/bar/baz.txt", { globstar: true }), false); t.equal( match("**/.txt", "/foo/bar/baz/qux.txt", { globstar: true }), - false + false, ); t.equal( match("*/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }), - false + false, ); t.equal(match("*/*.txt", "foo.txt", { globstar: true }), false); t.equal( @@ -574,65 +574,65 @@ Deno.test({ extended: true, globstar: true, }), - false + false, ); t.equal( match("http://foo.com/*", "http://foo.com/bar/baz/jquery.min.js", { globstar: true, }), - false + false, ); t.equal( match("http://foo.com/*", "http://foo.com/bar/baz/jquery.min.js", { globstar: false, }), - true + true, ); t.equal( match("http://foo.com/**", "http://foo.com/bar/baz/jquery.min.js", { globstar: true, }), - true + true, ); t.equal( match( "http://foo.com/*/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", - { globstar: true } + { globstar: true }, ), - true + true, ); t.equal( match( "http://foo.com/**/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", - { globstar: true } + { globstar: true }, ), - true + true, ); t.equal( match( "http://foo.com/*/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", - { globstar: false } + { globstar: false }, ), - true + true, ); t.equal( match( "http://foo.com/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", - { globstar: false } + { globstar: false }, ), - true + true, ); t.equal( match( "http://foo.com/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", - { globstar: true } + { globstar: true }, ), - false + false, ); }, }); @@ -646,46 +646,46 @@ Deno.test({ t.equal(match("?(foo|bar)baz.txt", "foobaz.txt", { extended: true }), true); t.equal( match("?(ba[zr]|qux)baz.txt", "bazbaz.txt", { extended: true }), - true + true, ); t.equal( match("?(ba[zr]|qux)baz.txt", "barbaz.txt", { extended: true }), - true + true, ); t.equal( match("?(ba[zr]|qux)baz.txt", "quxbaz.txt", { extended: true }), - true + true, ); t.equal( match("?(ba[!zr]|qux)baz.txt", "batbaz.txt", { extended: true }), - true + true, ); t.equal(match("?(ba*|qux)baz.txt", "batbaz.txt", { extended: true }), true); t.equal( match("?(ba*|qux)baz.txt", "batttbaz.txt", { extended: true }), - true + true, ); t.equal(match("?(ba*|qux)baz.txt", "quxbaz.txt", { extended: true }), true); t.equal( match("?(ba?(z|r)|qux)baz.txt", "bazbaz.txt", { extended: true }), - true + true, ); t.equal( match("?(ba?(z|?(r))|qux)baz.txt", "bazbaz.txt", { extended: true }), - true + true, ); t.equal(match("?(foo).txt", "foo.txt", { extended: false }), false); t.equal( match("?(foo|bar)baz.txt", "foobarbaz.txt", { extended: true }), - false + false, ); t.equal( match("?(ba[zr]|qux)baz.txt", "bazquxbaz.txt", { extended: true }), - false + false, ); t.equal( match("?(ba[!zr]|qux)baz.txt", "bazbaz.txt", { extended: true }), - false + false, ); }, }); @@ -708,21 +708,21 @@ Deno.test({ t.equal(match("*(foo|b*[rt]).txt", "tlat.txt", { extended: true }), false); t.equal( match("*(*).txt", "whatever.txt", { extended: true, globstar: true }), - true + true, ); t.equal( match("*(foo|bar)/**/*.txt", "foo/hello/world/bar.txt", { extended: true, globstar: true, }), - true + true, ); t.equal( match("*(foo|bar)/**/*.txt", "foo/world/bar.txt", { extended: true, globstar: true, }), - true + true, ); }, }); @@ -745,15 +745,15 @@ Deno.test({ t.equal(match("@(foo|baz)bar.txt", "foobar.txt", { extended: true }), true); t.equal( match("@(foo|baz)bar.txt", "foobazbar.txt", { extended: true }), - false + false, ); t.equal( match("@(foo|baz)bar.txt", "foofoobar.txt", { extended: true }), - false + false, ); t.equal( match("@(foo|baz)bar.txt", "toofoobar.txt", { extended: true }), - false + false, ); }, }); @@ -766,11 +766,11 @@ Deno.test({ t.equal(match("!bar.txt", "!bar.txt", { extended: true }), true); t.equal( match("!({foo,bar})baz.txt", "notbaz.txt", { extended: true }), - true + true, ); t.equal( match("!({foo,bar})baz.txt", "foobaz.txt", { extended: true }), - false + false, ); }, }); @@ -791,35 +791,35 @@ Deno.test({ match("**/*/?yfile.{md,js,txt}", "foo/bar/baz/myfile.md", { extended: true, }), - true + true, ); t.equal( match("**/*/?yfile.{md,js,txt}", "foo/baz/myfile.md", { extended: true }), - true + true, ); t.equal( match("**/*/?yfile.{md,js,txt}", "foo/baz/tyfile.js", { extended: true }), - true + true, ); t.equal( match("[[:digit:]_.]/file.js", "1/file.js", { extended: true }), - true + true, ); t.equal( match("[[:digit:]_.]/file.js", "2/file.js", { extended: true }), - true + true, ); t.equal( match("[[:digit:]_.]/file.js", "_/file.js", { extended: true }), - true + true, ); t.equal( match("[[:digit:]_.]/file.js", "./file.js", { extended: true }), - true + true, ); t.equal( match("[[:digit:]_.]/file.js", "z/file.js", { extended: true }), - false + false, ); }, }); diff --git a/std/path/_util.ts b/std/path/_util.ts index 0c3253045..ead425a0b 100644 --- a/std/path/_util.ts +++ b/std/path/_util.ts @@ -16,7 +16,7 @@ import { export function assertPath(path: string): void { if (typeof path !== "string") { throw new TypeError( - `Path must be a string. Received ${JSON.stringify(path)}` + `Path must be a string. Received ${JSON.stringify(path)}`, ); } } @@ -41,7 +41,7 @@ export function normalizeString( path: string, allowAboveRoot: boolean, separator: string, - isPathSeparator: (code: number) => boolean + isPathSeparator: (code: number) => boolean, ): string { let res = ""; let lastSegmentLength = 0; @@ -106,11 +106,11 @@ export function normalizeString( export function _format( sep: string, - pathObject: FormatInputPathObject + pathObject: FormatInputPathObject, ): string { const dir: string | undefined = pathObject.dir || pathObject.root; - const base: string = - pathObject.base || (pathObject.name || "") + (pathObject.ext || ""); + const base: string = pathObject.base || + (pathObject.name || "") + (pathObject.ext || ""); if (!dir) return base; if (dir === pathObject.root) return dir + base; return dir + sep + base; diff --git a/std/path/basename_test.ts b/std/path/basename_test.ts index b0694de20..9e2265db9 100644 --- a/std/path/basename_test.ts +++ b/std/path/basename_test.ts @@ -32,7 +32,7 @@ Deno.test("basename", function () { // On unix a backslash is just treated as any other character. assertEquals( path.posix.basename("\\dir\\basename.ext"), - "\\dir\\basename.ext" + "\\dir\\basename.ext", ); assertEquals(path.posix.basename("\\basename.ext"), "\\basename.ext"); assertEquals(path.posix.basename("basename.ext"), "basename.ext"); @@ -44,7 +44,7 @@ Deno.test("basename", function () { const controlCharFilename = "Icon" + String.fromCharCode(13); assertEquals( path.posix.basename("/a/b/" + controlCharFilename), - controlCharFilename + controlCharFilename, ); }); diff --git a/std/path/common_test.ts b/std/path/common_test.ts index 921cf1c99..7b7bd2ba3 100644 --- a/std/path/common_test.ts +++ b/std/path/common_test.ts @@ -11,7 +11,7 @@ Deno.test({ "file://deno/std/path/mod.ts", "file://deno/cli/js/main.ts", ], - "/" + "/", ); assertEquals(actual, "file://deno/"); }, @@ -22,7 +22,7 @@ Deno.test({ fn() { const actual = common( ["file://deno/cli/js/deno.ts", "https://deno.land/std/path/mod.ts"], - "/" + "/", ); assertEquals(actual, ""); }, @@ -37,7 +37,7 @@ Deno.test({ "c:\\deno\\std\\path\\mod.ts", "c:\\deno\\cli\\js\\main.ts", ], - "\\" + "\\", ); assertEquals(actual, "c:\\deno\\"); }, diff --git a/std/path/dirname_test.ts b/std/path/dirname_test.ts index bdf3391a9..210d3a9ec 100644 --- a/std/path/dirname_test.ts +++ b/std/path/dirname_test.ts @@ -40,15 +40,15 @@ Deno.test("dirnameWin32", function () { assertEquals(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\"); assertEquals( path.win32.dirname("\\\\unc\\share\\foo\\bar"), - "\\\\unc\\share\\foo" + "\\\\unc\\share\\foo", ); assertEquals( path.win32.dirname("\\\\unc\\share\\foo\\bar\\"), - "\\\\unc\\share\\foo" + "\\\\unc\\share\\foo", ); assertEquals( path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"), - "\\\\unc\\share\\foo\\bar" + "\\\\unc\\share\\foo\\bar", ); assertEquals(path.win32.dirname("/a/b/"), "/a"); assertEquals(path.win32.dirname("/a/b"), "/a"); diff --git a/std/path/glob.ts b/std/path/glob.ts index 5288efda9..172587626 100644 --- a/std/path/glob.ts +++ b/std/path/glob.ts @@ -41,7 +41,7 @@ export interface GlobToRegExpOptions extends GlobOptions { */ export function globToRegExp( glob: string, - { extended = false, globstar = true }: GlobToRegExpOptions = {} + { extended = false, globstar = true }: GlobToRegExpOptions = {}, ): RegExp { const result = globrex(glob, { extended, @@ -57,7 +57,8 @@ export function globToRegExp( export function isGlob(str: string): boolean { const chars: Record<string, string> = { "{": "}", "(": ")", "[": "]" }; /* eslint-disable-next-line max-len */ - const regex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; + const regex = + /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; if (str === "") { return false; @@ -89,7 +90,7 @@ export function isGlob(str: string): boolean { /** Like normalize(), but doesn't collapse "**\/.." when `globstar` is true. */ export function normalizeGlob( glob: string, - { globstar = false }: GlobOptions = {} + { globstar = false }: GlobOptions = {}, ): string { if (glob.match(/\0/g)) { throw new Error(`Glob contains invalid characters: "${glob}"`); @@ -100,7 +101,7 @@ export function normalizeGlob( const s = SEP_PATTERN.source; const badParentPattern = new RegExp( `(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, - "g" + "g", ); return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, ".."); } @@ -108,7 +109,7 @@ export function normalizeGlob( /** Like join(), but doesn't collapse "**\/.." when `globstar` is true. */ export function joinGlobs( globs: string[], - { extended = false, globstar = false }: GlobOptions = {} + { extended = false, globstar = false }: GlobOptions = {}, ): string { if (!globstar || globs.length == 0) { return join(...globs); diff --git a/std/path/glob_test.ts b/std/path/glob_test.ts index 1c90e765a..dba79c302 100644 --- a/std/path/glob_test.ts +++ b/std/path/glob_test.ts @@ -13,33 +13,33 @@ Deno.test({ assertEquals(globToRegExp("*.ts").test("unicorn.js"), false); assertEquals( globToRegExp(join("unicorn", "**", "cathedral.ts")).test( - join("unicorn", "in", "the", "cathedral.ts") + join("unicorn", "in", "the", "cathedral.ts"), ), - true + true, ); assertEquals( globToRegExp(join("unicorn", "**", "cathedral.ts")).test( - join("unicorn", "in", "the", "kitchen.ts") + join("unicorn", "in", "the", "kitchen.ts"), ), - false + false, ); assertEquals( globToRegExp(join("unicorn", "**", "bathroom.*")).test( - join("unicorn", "sleeping", "in", "bathroom.py") + join("unicorn", "sleeping", "in", "bathroom.py"), ), - true + true, ); assertEquals( globToRegExp(join("unicorn", "!(sleeping)", "bathroom.ts"), { extended: true, }).test(join("unicorn", "flying", "bathroom.ts")), - true + true, ); assertEquals( globToRegExp(join("unicorn", "(!sleeping)", "bathroom.ts"), { extended: true, }).test(join("unicorn", "sleeping", "bathroom.ts")), - false + false, ); }, }); @@ -59,7 +59,7 @@ testWalk( assertEquals(arr.length, 2); assertEquals(arr[0], "a/x.ts"); assertEquals(arr[1], "b/z.ts"); - } + }, ); testWalk( @@ -79,7 +79,7 @@ testWalk( }); assertEquals(arr.length, 1); assertEquals(arr[0], "a/yo/x.ts"); - } + }, ); testWalk( @@ -104,7 +104,7 @@ testWalk( assertEquals(arr.length, 2); assertEquals(arr[0], "a/deno/x.ts"); assertEquals(arr[1], "a/raptor/x.ts"); - } + }, ); testWalk( @@ -120,7 +120,7 @@ testWalk( assertEquals(arr.length, 2); assertEquals(arr[0], "x.js"); assertEquals(arr[1], "x.ts"); - } + }, ); Deno.test({ diff --git a/std/path/posix.ts b/std/path/posix.ts index 351ceb06e..03d07a84a 100644 --- a/std/path/posix.ts +++ b/std/path/posix.ts @@ -50,7 +50,7 @@ export function resolve(...pathSegments: string[]): string { resolvedPath, !resolvedAbsolute, "/", - isPosixPathSeparator + isPosixPathSeparator, ); if (resolvedAbsolute) { @@ -337,7 +337,7 @@ export function format(pathObject: FormatInputPathObject): string { /* eslint-disable max-len */ if (pathObject === null || typeof pathObject !== "object") { throw new TypeError( - `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}` + `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`, ); } return _format("/", pathObject); diff --git a/std/path/win32.ts b/std/path/win32.ts index 30482e453..66ed1ff14 100644 --- a/std/path/win32.ts +++ b/std/path/win32.ts @@ -167,7 +167,7 @@ export function resolve(...pathSegments: string[]): string { resolvedTail, !resolvedAbsolute, "\\", - isPathSeparator + isPathSeparator, ); return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || "."; @@ -259,7 +259,7 @@ export function normalize(path: string): string { path.slice(rootEnd), !isAbsolute, "\\", - isPathSeparator + isPathSeparator, ); } else { tail = ""; @@ -750,7 +750,7 @@ export function format(pathObject: FormatInputPathObject): string { /* eslint-disable max-len */ if (pathObject === null || typeof pathObject !== "object") { throw new TypeError( - `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}` + `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`, ); } return _format("\\", pathObject); |