nickdodd79 / vscode-gulptasks

A gulp task visualization and execution extension for Visual Studio Code
MIT License
7 stars 6 forks source link

filters setting not working? #13

Closed gilluminate closed 6 years ago

gilluminate commented 6 years ago

Getting the following error every time I open VSCode suggesting that the extension is not ignoring node_modules as intended by the default filters setting

Gulp Tasks: Command failed: gulp --tasks-simple --gulpfile "[_full path to my project_]/node_modules/gulp-chug/gulpfile.js" module.js:549 throw err; ^ Error: Cannot find module 'gulp-istanbul' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object.<anonymous> (node_modules/gulp-chug/gulpfile.js:2:19) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3)

nickdodd79 commented 6 years ago

Yeah that does seem weird. I'll do some investigations. If you remove the filters (so empty array) does it try to use any other node_module files (assuming it will get that far)?

gilluminate commented 6 years ago

Setting filters to an empty array gives the exact same result.

BTW, if I remove that gulpfile from node_modules, I get a similar error but for a different npm module, so I guess it's only displaying the first error to me.

nickdodd79 commented 6 years ago

Ok cool. That definitely does seem like the filters have stopped working. Could be a case sensitive thing. What environment are you in (e.g. windows, linux, etc.).

gilluminate commented 6 years ago

MacOS: 10.13.5 (High Sierra) VS Code: 1.24.0

nickdodd79 commented 6 years ago

Hey @gilluminate

I have taken a look and everything is working as expected, but I am on a Windows machine, so it would seem to be an OS quirk. I shall do some more investigations - I have an iMac floating around somewhere.

Watch this space.

Nick.

nickdodd79 commented 6 years ago

I installed gulp-chug to a test project and I think I have managed to replicate your error message:

ERROR: Command failed: gulp --tasks-simple --gulpfile "p:\test\node_modules\gulp-chug\gulpfile.js"
internal/modules/cjs/loader.js:596
    throw err;
    ^

Error: Cannot find module 'gulp-istanbul'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (p:\test\node_modules\gulp-chug\gulpfile.js:2:19)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)

But I had to remove the node_modules value from from filter settings:

"gulptasks.filters": [
  "!bower_components/**"
]

Can you check your gulptasks.filters value. My test project ignores gulp-chug with the following filters (which are the defaults):

"gulptasks.filters": [
  "!node_modules/**",
  "!bower_components/**"
]
gilluminate commented 6 years ago

Yeah, that's weird. I didn't originally have anything in my settings, which should be respecting that default. I've tried an empty array, bower only and the full defaults set explicitly. Nothing seems to help.

I even added that full default to both my user settings and my workspace settings. Nada.

nickdodd79 commented 6 years ago

Hmm ok. I dug out my iMac so will try some testing in that environment.

nickdodd79 commented 6 years ago

Hi @gilluminate

I am still looking into this and trying to replicate it. I have been a little time poor over the last week or so, but will be trying to get back into setting up my mac and providing a solution.

Nick.

gilluminate commented 6 years ago

Thanks, Nick. I keep meaning to find some time to try it out without any other extensions just to be sure it's not a conflict issue, but haven't had much time either. So, I totally understand :)

nickdodd79 commented 6 years ago

Hi @gilluminate

I finally managed to try and replicate your issue on my iMac with no luck. I installed gulp and gulp-chug in a test project and everything loaded up in the extension as expected.

It would seem your suggestion around conflicts might be the next avenue to explorer.

I will close this issue, but if you do track down the cause, I'd been keen to learn what it was so I can implement some safe guarding. Just add another comment here.

Thanks,

Nick.

gilluminate commented 6 years ago

Ok, @nickdodd79 I figured out what the problem was. I am using a multi-root Workspace in VS Code. As such, the results from the gulpfile query were returned with my root directory appended to the beginning. So the solution was to use:

"gulptasks.filters": [
    "!**/node_modules/**"
]

That may be something you want to call out in your documentation for other multi-root users.

Thanks, Jason

nickdodd79 commented 6 years ago

Hey @gilluminate

Awesome. Thanks for the update. That makes total sense and is certainly a scenario if neglected to test, so I shall be all over it both in terms of a fix moving forward and getting some documentation out there.

Thanks again...great work :-)

Nick.

shreeshkatyayan commented 6 years ago

@gilluminate we're talking about workspace settings here, right? I am facing the same error and somehow remains unsolved even after going through this thread.

Environment specifications

VSCode - Version 1.24.1 Gulp Tasks - Version 1.1.2 Gulp CLI - Version 3.9.1 MacOS - 10.12.6 (Sierra)

gilluminate commented 6 years ago

@shreeshkatyayan yes, in my case I solved it in Workspace settings.

nickdodd79 commented 6 years ago

Hey @shreeshkatyayan

Apologies, I have been a bit slack and time poor with putting a more global fix for this in place and adding some documentation. I will endevour to get something done shortly.

Nick.

nickdodd79 commented 6 years ago

I have now added the necessary default settings so this should just work for both single and multi-root workspaces. If, however, you have custom filters defined, you will need to alter them to use the notation provided by @gilluminate (i.e. prefix with a **).

shreeshkatyayan commented 6 years ago

@nickdodd79 greatly appreciate you taking out time 😄have received the update to the package. I think there's something amiss in how I'm perceiving the filter (I highly doubt though that this is the case).

My project setup is:

Workspace
|-- Client
      |-- User
      |     |-- gulpfile.js
      |     |-- node_modules
      |     |-- bower_components
      |
      |-- Admin
      |     |-- gulpfile.js
      |     |-- node_modules
      |     |-- bower_components
      |
      |-- Internal
      |     |-- gulpfile.js
      |     |-- node_modules
      |     |-- bower_components
|-- Server (not relevant here)
nickdodd79 commented 6 years ago

Hey @shreeshkatyayan

When the discovery process attempts to locate the gulp files in your workspace, the filters are used to exclude any matches that should not be added to the gulp tasks tree. This is generally node_modules and bower_components by default. You also have the option to override these defaults to include your own filters via Preferences > Settings. So in you your project setup, you could filter out the Server folder by adding a !Server/** filter.

Originally, the default filter for node_modules was !node_modules/**, which meant it would only exclude gulp files in node_modules if node_modules was at the workspace root. This is not the case when a multiple root approach is used. Therefore, the filters have now been updated to exclude node_modules at any level - !**/node_modules/** (note the ** at the start).

So, based on the that lengthy introduction, your project structure should result in 3 files being added to the gulp tasks tree (assuming the Server folder has no gulp files) - Client/User/gulpfile.js, Client/Admin/gulpfile.js and Client/Interal/gulpfile.js. Nothing will be added from the node_modules or bower_components as long as the new filter definitions are in place.

gulptasks.filters: [
  "!**/node_modules/**",
  "!**/bower_components/**"
]

Are you receiving an error during the discovery process? If so, can you list it here and any gulp.tasks overrides you have in your Preferences > Settings.

Nick.

shreeshkatyayan commented 6 years ago

That's exactly how I intended it to be behaving, but still getting the same issue. Fetching gulpfiles gets stuck at . Will try to debug it and let you know the problem by next week. Superbusy work week for now 🤒