adelsz / pgtyped

pgTyped - Typesafe SQL in TypeScript
https://pgtyped.dev
MIT License
2.91k stars 94 forks source link

SQL transform mode including node_modules files #534

Open oste opened 1 year ago

oste commented 1 year ago

Describe the bug I am running pgtyped in SQL mode and noticing extra files unrelated to the include config is being parsed.

Expected behavior Only files within the srcDir that match the include pattern should be parsed.

Test case

I can't provide a test case but I am using the following config.json

{
  "transforms": [
    {
      "mode": "sql",
      "include": "**/*.sql",
      "emitTemplate": "{{dir}}/{{name}}.queries.ts"
    }
  ],
  "srcDir": "./packages/sql/",
  "failOnError": false,
  "camelCaseColumnNames": false,
  "dbUrl": "postgres://postgres:postgres@localhost/target-db"
}

With the following output npx pgtyped -w -c config.json:

Using a pool of 5 threads.
Processing packages/sql/test.sql
Processing packages/sql/node_modules/.bin/tsc
Processing packages/sql/node_modules/.bin/tsserver

Parsed file:
1 > #!/usr/bin/env node
2 | require('../lib/tsserver.js')
3 |
Errors:
- (1:0) Parse error: mismatched input '#' expecting '/*'

Parsed file:
1 > #!/usr/bin/env node
2 | require('../lib/tsc.js')
3 |
Errors:
- (1:0) Parse error: mismatched input '#' expecting '/*'
- 
Skipped packages/sql/node_modules/.bin/tsserver: no changes or no queries detected
Skipped packages/sql/node_modules/.bin/tsc: no changes or no queries detected
Skipped packages/sql/test.sql: no changes or no queries detected