【问题标题】:Excluding a portion of filename with glob expressionExcluding a portion of filename with glob expression
【发布时间】:2022-12-02 04:10:33
【问题描述】:

I'm having trouble excluding test files from my glob expression as follows : I have this list of files

./app/tags.ts
./app/tag.ts
./app/status.ts
./app/bar/{foo}/baz.ts
./app/.hidden.ts
./app/_hidden.ts
./app/foo_dir/.hidden.ts
./app/some/testing_should_be_hidden.test.ts

I'm trying to exclude everything that starts with a '.' or starts with a '_' or includes a '.test' in the filename

so far this is what I tried :

Glob file pattern excluding node_modules

with my expression :

./**/[!._]*^(?!*test).{ts,js}

but It didn't work, however using:

./**/[!._]*.{ts,js}

excludes the 'hidden' files but not the test one

FYI : test is available here : https://www.digitalocean.com/community/tools/glob?comments=false&glob=.%2F%2A%2A%2F%5B%21._%5D%2A%5E%28%3F%21%2Atest%29.%7Bts%2Cjs%7D&matches=false&tests=.%2Fapp%2Ftags.ts&tests=.%2Fapp%2Fgame%2F%7BgameId%7D%2Fclip.ts&tests=.%2Fapp%2F.hidden.ts&tests=.%2Fapp%2F_hidden.ts&tests=.%2Fapp%2Fgame%2F.hidden.ts&tests=.%2Fapp%2Fsome%2Ftesting.test.ts

【问题讨论】:

    标签: glob


    【解决方案1】:

    So far this worked for me :

    ./**/[!._]!(*.test).{ts,js}
    

    Can anyone explain this to me? I'm confused ...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 2016-06-17
      • 2022-12-01
      • 2023-02-26
      • 1970-01-01
      相关资源
      最近更新 更多