0

I need regex to add to the tsconfig file. I'm trying to match only ts source files, but not test files.

Tried something like;

  "include": [
    "src/**/*",
    "../../node_modules/@web/common/src/app/views/**/*.ts"
    "../../node_modules/@web/common/src/app/views/**/*.(module|component).ts"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts",
    "../../**/*.spec.ts"

But no luck.

// should match
/main.ts
/hello-world.component.ts

// shouldn't match
/hello-world.component.spec.ts
/app.e2e-spec.ts
Mohamed
  • 71
  • 3
  • 7
  • Do you use a specific programming language? What did you try so far? – Darius Feb 13 '19 at 16:06
  • Javascript. Currently using "/**/*.ts" – Mohamed Feb 13 '19 at 16:08
  • That isn't regex. Doesn't tsconfig have an "exclude" section? "xx/x.spec.ts" where x is * – Andy G Feb 13 '19 at 16:12
  • Did you try something like `"/**/*!(*spec.ts)"`? If your are using `glob`, there is a [ignore section](https://stackoverflow.com/questions/23809897/node-js-glob-pattern-for-excluding-multiple-files/27313981) to exclude files. – Darius Feb 13 '19 at 16:16
  • "But no luck" Are you sure that it isn't working? Maybe it needs some housekeeping from an earlier run. – Andy G Feb 13 '19 at 16:33
  • I think I e=need regex to match only component module service ts files but not test e2e etc. I don't think exclude works at all. – Mohamed Feb 13 '19 at 16:55

1 Answers1

0

The tsconfig file has an exclude section to exclude files based on a pattern match. For example:

"include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]

the handbook

Andy G
  • 19,232
  • 5
  • 47
  • 69