'current project path' within a Gulp task
Followed by 2 people
I am trying to get the 'current project path' within a Gulp task and run this on Startup. At the moment I have access to the 'current project path' running Gulp manually from the terminal because the terminal has the 'current working directory' (CWD) set to the 'current project path'.
But I can't get it to work starting the task automatically. I Tried using 'Run Configurations' but this isn't working because the Gulp file is located somewhere else. So it will have the CWD set to the location of the Gulp file and not to the 'current project path'.
I need some kind of $ProjectFileDir$ but this is only working with 'External tools'. But External tools I cant use because I need to manually set a Program. This will be annoying due to the fact I need to set this up on different computers including pc's and macs. Or I need a way to Auto run a terminal command.
I am kind of stuck here.
Please sign in to leave a comment.
$ProjectFileDir$ is not exposed and can't be used in code/run configurations; and there is no way to change working directory in Gulp run configuration (https://youtrack.jetbrains.com/issue/WEB-24132).
So I can only suggest hardcoding the needed dir in your task code - you can search for nearest dir with package.json, for example
possible solution (not too smart:():
- create a batch script that writes input parameter to file, like:
- set up this script as external tool, passing $ProjectFileDir$ to it as an argument
- add this tool as "Before launch" task to your Gulp run configuration
- read a value from file in your Gulp task, like:
Thanks for your reply. This last answer is nice when you want to auto start a task with 'current project path' for s single project. I wasn't clear. But we want to start a Gulp task for any project we load because we have manyyy small projects where we want to start a gulp task to always watch the Typescript file (as the native typescript also can do). So In my case 'Run Configurations' wouldn't be useful anyway because this is per project.
I did find however another way to always start the gulp task in a project environment. Adding a terminal command as shown below. I guess the same settings could be applied per project as well.
Of course this is very hacky because now every console will start running this task.