Giter Site home page Giter Site logo

Comments (7)

stephenlacy avatar stephenlacy commented on July 19, 2024

Git is only able to track files in it's working tree, where the .git folder exists.
The workaround is to modify the working directory's: https://stackoverflow.com/questions/5283262/what-is-git-work-tree-why-have-i-never-needed-to-set-this-env-var-why-now

from gulp-git.

that1guy avatar that1guy commented on July 19, 2024

There is already a .git folder in the directory the files are being copied into. For example I could run all my gulp tasks (except git add/push)... and then I could manually change into this directory add/push everything. Would this mean that gulp-git could do the same? Thanks for quick reply!

from gulp-git.

stephenlacy avatar stephenlacy commented on July 19, 2024

Ah, so you would want to change the gulp cwd: https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md

And or git.add({cwd:'../hts_node_prod/*'})
Src line

from gulp-git.

that1guy avatar that1guy commented on July 19, 2024

This makes sense. Sorry to be bother, but I'm still racking my brain here:

[22:37:57] Starting 'move'...
[22:37:58] Finished 'move' after 625 ms
[22:37:58] Starting 'minify-css'...
[22:37:58] Finished 'minify-css' after 112 ms
[22:37:58] Starting 'minify-js'...
[22:37:59] Finished 'minify-js' after 673 ms
[22:37:59] Starting 'add'...
[22:37:59] 'add' errored after 17 ms
[22:37:59] Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)
[22:37:59]  
var gulp = require('gulp')
, minifyCss = require("gulp-minify-css")
, uglify = require("gulp-uglify")
, git = require('gulp-git');



var filesToMove = [
        './.gitignore',
        './.ebextensions/**/*.*',
        './api/**/*.*',
        './app/**/*.*',
        './config/**/*.*',
        './email_templates/**/*.*',
        './public/**/*.*',
        './package.json',
        './server.js'
    ];



//move necessary files into the _deploy dir
gulp.task('move', function(cb){
  // the base option sets the relative root for the set of files,
  // preserving the folder structure
  var stream = gulp.src(filesToMove, { base: './' })
      .pipe(gulp.dest('../hts_node_prod'));
  return stream;
});




//minify css
gulp.task('minify-css', ['move'], function (cb) {
    var stream = gulp.src('../hts_node_prod/public/css/*.css') // path to your file.
        .pipe(minifyCss())
        .pipe(gulp.dest('../hts_node_prod/public/css/'));
    return stream;
});


//minify js
gulp.task('minify-js', ['minify-css'], function (cb) {

    var stream = gulp.src('../hts_node_prod/public/modules/**/*.js') // path to your files
        .pipe(uglify({compress: {drop_console: true }}))
        .pipe(gulp.dest('../hts_node_prod/public/modules/'));
    return stream;
});


// Run git add
// src is the file(s) to add (or ./*)
gulp.task('add', ['minify-js'], function(cb){

    //ERRORS HERE**********

    var stream = gulp.src('../hts_node_prod/*')
        .pipe(git.add({cwd:'../hts_node_prod/*'}));
    return stream
});



// Run git commit
// src are the files to commit (or ./*)
gulp.task('commit', ['add'], function(cb){

    var timestamp = new Date().getTime();

    console.log(timestamp);

    var stream = gulp.src('../hts_node_prod/*')
        .pipe(git.commit(""+timestamp+"", {cwd:'../hts_node_prod/*'}));
    return stream
});



// push all new commits to production bitbucket
gulp.task('push', ['commit'], function(){
    git.push('origin', 'master', function (err) {
        if (err) throw err;
    });
});


gulp.task('default', ['push']);

from gulp-git.

stephenlacy avatar stephenlacy commented on July 19, 2024

Add the CWD to the gulp.src as well. https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md

from gulp-git.

that1guy avatar that1guy commented on July 19, 2024

Thank you! Solved.

// Run git add
// src is the file(s) to add (or ./*)
gulp.task('add', ['minify-js'], function(cb){

    var stream = gulp.src('./*', {cwd:'/Library/Webserver/Documents/hts_node_prod/'})
        .pipe(git.add({cwd:'/Library/Webserver/Documents/hts_node_prod/'}));
    return stream
});



// Run git commit with options
gulp.task('commit', ['add'], function(cb){
    var stream = gulp.src('./*', {cwd:'/Library/Webserver/Documents/hts_node_prod/'})
        .pipe(git.commit('gulp commit', {cwd:'/Library/Webserver/Documents/hts_node_prod/'}));
    return stream
});



// push all new commits to production bitbucket
gulp.task('push', ['commit'], function(cb){
    var stream = gulp.src('./*', {cwd:'/Library/Webserver/Documents/hts_node_prod/'})
        .pipe(git.push('origin', 'master', {cwd:'/Library/Webserver/Documents/hts_node_prod/'}, function (err) {
            if (err) throw err;
        }));
    return stream
});

from gulp-git.

stephenlacy avatar stephenlacy commented on July 19, 2024

Excellent!
I will close this now. If you would like you could send a PR with an example to the examples folder.

from gulp-git.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.