I'm building a frontend workflow with gulp where i need to be able to build multiple separate designs but they need to share some common settings.
To clarify, i have a structure like this:
gulp in templates/designs/mydesign1 or templates/designs/mydesign2 and have acess to the data inside [Project root]/sftp-config.json and [Project root]/.eslintrc and any other file that might exist outside of the folder that gulp was run from.
Is that possible?
I found a solution to my problem, and it seems to work pretty well for my needs:
By using process.cwd() i can get the folder that gulp ran in, and then i can use path.resolve('../') to step back in my folders until i hit my project root folder.
var gulpRanInThisFolder = process.cwd();
var rootDir = path.resolve('../','../','../','../');
var designFolderName = pkg.name;
var sftpConfigPath = path.join(rootDir, '/sftp-config.json');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With