question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

project.getSourceFiles() filtering not working in v11

See original GitHub issue

Describe the bug

Version: 11.0.3

project.getSourceFiles() // return --> all files

Works just fine

project.getSourceFiles('**/*.ts') // return -> [] (doesn't get the files)

project.getSourceFiles('exact/file/path/to/file') // return -> [] (doesn't get the files)

project.getSourceFile('exact/file/path/to/file') // return -> undefined (doesn't get the file)

This doesn’t.

To Reproduce

const projectDirectory = '/someDirectory'
const projectConfigFile = path.join(projectDirectory, 'tsconfig.json')
const project = new Project({
    tsConfigFilePath: projectConfigFile,
})

const sourceFilesAll = project.getSourceFiles() // return --> [...source files (all)...]
const sourceFilesFiltered = project.getSourceFiles('**/*.ts') // return --> [] (empty)

Expected behavior

Filters should just works well!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
dsherretcommented, Aug 7, 2021

Why such a behavior ? … Shouldn’t normally the matching go automatically relatively to the project directory ?

It’s done this way because then all the paths use the same directory as the base including at project initialization. Additionally, when you use project.getFileSystem() everything will be relative from the cwd. I don’t believe it would make sense to make it relative based on the directory of the tsconfig once you initialize. For example, say there was the following structure and the cwd was the root:

/project1
  tsconfig.json
  mod.ts
/project2
  tsconfig.json
  mod.ts
/project3
  mod.ts

I’m not sure it would be desirable to work this way:

const project = new Project({ tsConfigFilePath: "./project1/tsconfig.json" }); // relative CWD
project.addSourceFilesFromTsConfig("../project2/tsconfig.json"); // relative from project1
project.addSourceFiles("../project3/**/*.ts"); // relative from project1

I would expect the current behaviour:

const project = new Project({ tsConfigFilePath: "./project1/tsconfig.json" }); // relative CWD
project.addSourceFilesFromTsConfig("./project2/tsconfig.json");  // relative CWD
project.addSourceFiles("./project3/**/*.ts"); // relative CWD

Also i would like to add such a detail to the source files documentation. I Would add a small block if it’s right ? That can save good time for many. is contribution to documentation acceptable ?

Sure, thanks! That would be great to add something saying that it’s based on the current working directory.

2reactions
dsherretcommented, Aug 7, 2021

Could you provide more details and something I could take to reproduce this? I’m not sure what files exist in that project. What you’re doing should work. Perhaps the current working directory is different and you need to do ${projectDirectory}/**/*.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filter Drop-Down Not Working in Excel - YouTube
In this video I explore eight reasons why filtering in Excel is not working properly (or at all!).Table of Contents: 00:00 ...
Read more >
Filter tasks or resources - Microsoft Support
With Project, you can filter your view so that you only see the critical tasks, milestones, and other information that's most important to...
Read more >
JQL Filter not working for filtering issues in the second board
I have 2 teams working on the same project. I created a JQL filter and shared it with the project but its not...
Read more >
Filtering projects - GitHub Docs
Use filters to choose which items appear in your project's views. You can customize views using filters for item metadata, such as assignees...
Read more >
5 Reasons why your Excel filter may not be working
5 Reasons why your Excel filter may not be working · 1. Check that you have selected all of the data · 2....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found