scenario:
~/folder/gulpfile.js
~/folder/childfolder1 // no gulpfile.js in this folder
~/folder/childfolder2 // no gulpfile.js in this folder
running gulp under one of the child folder will load ~/folder/gulpfile.js
according to GULP change log 1.2-2.4 (11/12/13)
therefore when gulpfile.js is loaded, process.cwd() == "~/folder"
I want to share same gulpfile.js for all child folders,
my question is , how could the gulpfile knows it originate childfolder ?
could I get the child folder in gulpfile.js ?
for example , gulp.cwd() ?
@yapcheahshen To get the cwd in node you use process.cwd()
The process will be chdir'ed to whatever you pass in --cwd so all paths will be relative to there
@yapcheahshen Figured it out! :) Here's how you get the initial directory from Node:
console.log process.env.INIT_CWD #the initial directory
# ~/project/child_folder
console.log process.cwd() #gulpfile.js location
# ~/project
@robert-blankenship : Looking for this for over two hours. You are a life saver. Thanks!
Most helpful comment
@yapcheahshen Figured it out! :) Here's how you get the initial directory from Node: