Search code examples
gulp

Gulp: How to set users home directory in Gulp destination?


Is there a way I can read %USERPROFILE% directory in Gulp task and use it for destination to pipe to?

gulp.task('push-my-repos', function () {
    var baseDir = '../Bower-Learning-1';
    var dest = 'C://Users//user-1//AppData/Local//MY//Bower//Repos//**';
    var src = ['../**/*.*', '!./**/', '!../*.*'];
    console.log("%USERPROFILE%");
    return gulp.src(src, { base: baseDir})
    .pipe(gulp.dest(dest))
});

In this sample task I want to pick "dest" dynamically instead of hard coding so that my colleagues can run this task without changing it.


Solution

  • I made it work with the help of node environment variables.