Is there a way to set the working directory for Gulp in the gulpfile so that I can run the Gulp command from a subdirectory without any problems? I started the search and did not find what I was looking for.
To clarify, I know about adding a prefix to the files that I use. However, instead -
var gulp = require('gulp'); var jshint = require('gulp-jshint'); ... var paths = { js: [__dirname + 'app/*/*.js', __dirname + '!app/lib/**'], css: __dirname + 'app/*/*.styl', img: __dirname + 'app/img/*', index: __dirname + '*.html', dist: __dirname + 'dist' };
I would like to do something like this:
var gulp = require('gulp'); var jshint = require('gulp-jshint'); ... gulp.cwd(__dirname); // This would be much easier to understand, and would make future edits a bit safer. var paths = { js: ['app/*/*.js', '!app/lib/**'], css: 'app/*/*.styl', img: 'app/img/*', index: '*.html', dist: 'dist' };
I am wondering if this function reveals Gulp. Perhaps node itself allows this.
(I understand that when I run the command, there is a way to make the command itself, but I would like to include it in the Gulp file, especially for distribution purposes. I need a working directory for Gulp to match the directory where the gulpfile is located.)
Thanks!
source share