worker icon indicating copy to clipboard operation
worker copied to clipboard

Option to exclude file patterns from taskDirectory

Open abeluck opened this issue 5 years ago • 1 comments

Feature description

I'd like to propose a new option, something along the lines of exclude that would accept a list of strings containing the common matcher patterns like **.spec.js.

Files in the taskDirectory whose name matches one of the patterns would not be loaded by graphile-migrate.

Motivating example

We use the convention of placing our tests alongside actual code:

  • tasks/does-stuff.js
  • tasks/does-stuff.spec.js

Graphile chokes on the spec files of course.

/home/user/prj/link/amigo-starter/node_modules/graphile-worker/dist/getTasks.js:123
                        throw new Error(message);
                              ^

Error: Error processing '/home/user/myproj/build/main/tasks/hello.spec.js': describe is not defined

Breaking changes

There would be none

Supporting development

  • [x] am interested in collaborating on building this feature
  • [x] am willing to help testing this feature before it's released

abeluck avatar Nov 24 '20 12:11 abeluck

I'm very hesitant to add globbing to worker just for this. That said, there are other reasons you might want to use file patterns, for example if you want one worker to do your image processing tasks and another to do your email sending tasks (though this would be include rather than exclude).

I'm going to leave this open and see if this is a feature that is widely supported or not. If you want this feature, please add a :+1: reaction to the issue description above.

In the mean time, you can address this issue using the library interface by passing your own explicit taskList; the main drawback of this approach is that you'd lose/have to reimplement watch mode. Another solution is to put your tests into a __tests__ folder as is common in jest projects.

benjie avatar Nov 25 '20 15:11 benjie

In three years 4 people have expressed interest in this, so I'm going to close it for now; hopefully the taskList approach is sufficient... Alternatively a tasks folder containing symlinks might be another workaround?

benjie avatar Oct 20 '23 16:10 benjie