Skip to content

Commit

Permalink
Patch/discard remove git (#46)
Browse files Browse the repository at this point in the history
* Update fetch.js

* Update discard.js

* Update discard.js

* Updating with sync methods

* lint

* Updating check to remove .git

* ensuring conditional check for keep history flag works as expected
  • Loading branch information
howardroark committed Feb 21, 2017
1 parent f67fa31 commit 102d275
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
12 changes: 9 additions & 3 deletions lib/discard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@

var rimraf = require('rimraf');
var async = require('async');
var isDirectory = require('is-directory');

module.exports = function (state, callback) {
var discard = state.data.discard;
var discard = state.data.discard,
tmpPath = state.template.tmp;

// Remove the .git directory unless told otherwise
if (isDirectory.sync(tmpPath + '/.git') && !state.data.keepHistory && (!state.flags || !state.flags['keep-history'])) {
rimraf.sync(tmpPath + '/.git');
}

if (discard === undefined || discard.length === 0) {
callback(null, state);
Expand All @@ -22,7 +29,7 @@ module.exports = function (state, callback) {

async.parallel(discard.map(function (path) {
return function (next) {
rimraf(state.template.tmp + '/' + path, next);
rimraf(tmpPath + '/' + path, next);
};
}), function (err) {
if (err) {
Expand All @@ -34,4 +41,3 @@ module.exports = function (state, callback) {
});

};

13 changes: 0 additions & 13 deletions lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,6 @@ var fetchGit = function (state, callback) {
} else {
next(null);
}
},
function (next) {
if (isDirectory(tmpPath + '/.git') && !state.options.keepHistory && !(state.flags && state.flags['keep-history'])) {
fsExtra.remove(tmpPath + '/.git', function (err) {
if (err) {
next(err);
return;
}
next(null);
});
} else {
next(null);
}
}
], function (err) {
if (err) {
Expand Down
3 changes: 1 addition & 2 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ describe('Test basic example', function () {
pollinate({
"inputs": [
"https://github.com/howardroark/webapp.git",
"{\"name\":\"newproject\",\"container\":\"alpine\"}"
"{\"name\":\"newproject\",\"container\":\"alpine\", \"keepHistory\":true}"
],
"options": {
"keepHistory": true
//..
}
}, function (err, result) {
Expand Down

0 comments on commit 102d275

Please sign in to comment.