Comments (7)
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.
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.
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.
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.
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.
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.
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)
- Get current branch name? HOT 2
- git add is broken in Node 8 HOT 1
- git.add does not allow for specified files to add in another cwd HOT 4
- gulp-git breaks in Node 9.5.0. HOT 3
- Error creating commit on new git version HOT 20
- Error: i can't commit HOT 2
- How to use git clone with ssh HOT 2
- How to clone with a specified branch? HOT 5
- commit() will commit also unstaged files HOT 2
- Git add . all files HOT 2
- Cannot use '-a' anymore for commit HOT 4
- how can I checkout a file HOT 1
- stdout maxBuffer length exceeded (diff.js) HOT 1
- Problem with absolute path or Gulp v4
- Cherry-pick - feature request HOT 1
- finish event listener registration error
- Gulp 4 compatibility HOT 1
- Add rebase command HOT 2
- "The command line is too long." on `git.add()` HOT 1
- lodash.template critical vulnerabilities from Mend
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-git.