* [codeshift] add proper ignore comments * [codeshift] apply require-to-import transform * [codeshift/fixup] remove duplicate imports * [eslint] upgrade config for react "unused" support * [codeshift] apply remove-unused-imports transform * [codeshift] apply remove-unused-basic-requires transform * [codeshift] apply remove-unused-function-arguments transform * [lintroller] fix argument list spacing * [codeshift] apply remove-unused-basic-bars transform * [codeshift/fixup] fixup unused basic var removals * manually apply remove-unused-assignments transform * [codeshift] reapply remove-unused-imports transform * [codeshift] reapply remove-unused-function-arguments transform * [eslint] autofix param spacing * manually fix remaining no-undef errors * use more descriptive file ignore pattern * add eslint-plugin-react peerDependency * replace values that looked unused in tests * remove // kibana-jscodeshift-no-babel comment * remove import statements from code required by api tests * Remove '// kibana-jscodeshift-ignore' comments * address review feedback * remove remnant of removed if condition
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import Promise from 'bluebird';
|
|
import spawn from './spawn';
|
|
import grunt from 'grunt';
|
|
|
|
module.exports = function (repo, dir) {
|
|
// store the previous and new hash from the repo
|
|
// to know if there was an update from fetch
|
|
let prevHash;
|
|
let newHash;
|
|
|
|
return Promise.resolve()
|
|
.then(function () {
|
|
if (!grunt.file.isDir(dir + '/.git')) {
|
|
if (grunt.file.isDir(dir)) {
|
|
throw new Error(dir + ' needs to be removed so that we can replace it with a git-repo');
|
|
}
|
|
|
|
return spawn('git', ['clone', repo, dir])();
|
|
} else {
|
|
return spawn.silent('git', ['log', '-1', '--pretty=%H'], dir)()
|
|
.then(function (out) {
|
|
prevHash = out.trim();
|
|
})
|
|
.then(spawn('git', ['fetch', 'origin', 'master'], dir))
|
|
.then(spawn('git', ['reset', '--hard', 'origin/master'], dir))
|
|
.then(spawn.silent('git', ['log', '-1', '--pretty=%H'], dir));
|
|
}
|
|
})
|
|
.then(function (out) {
|
|
if (prevHash) newHash = out.trim();
|
|
if (!prevHash || newHash !== prevHash) {
|
|
return spawn('npm', ['update'], dir)()
|
|
.then(spawn('bower', ['install'], dir))
|
|
.then(function () {
|
|
return true;
|
|
});
|
|
}
|
|
});
|
|
};
|