|
|
@@ -1,3 +1,4 @@
|
|
|
+const Promise = require('bluebird');
|
|
|
const path = require('path');
|
|
|
const execAsync = require('./execAsync');
|
|
|
const appRoot = path.normalize(__dirname + '/..');
|
|
|
@@ -20,21 +21,29 @@ function gitStatusAsync(src, dst) {
|
|
|
}
|
|
|
|
|
|
function getUntrackedReposAndExamples() {
|
|
|
- gitStatusAsync()
|
|
|
+ return gitStatusAsync()
|
|
|
.then(({ stdout }) => {
|
|
|
let idx = stdout.indexOf('Untracked files:');
|
|
|
const output = stdout.substr(idx);
|
|
|
- let lines = output.split('\n');
|
|
|
+ let files = output.split('\n');
|
|
|
|
|
|
- lines.splice(0, 3);
|
|
|
+ files.splice(0, 3);
|
|
|
idx = 0;
|
|
|
- while(lines[idx]) idx++;
|
|
|
- lines.splice(idx, lines.length - idx);
|
|
|
- lines.forEach((line, i) => {
|
|
|
- lines[i] = line.trim();
|
|
|
+ while(files[idx]) idx++;
|
|
|
+ files.splice(idx, files.length - idx);
|
|
|
+ files.forEach((line, i) => {
|
|
|
+ files[i] = line.trim();
|
|
|
});
|
|
|
- console.log(lines);
|
|
|
+ return files;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-getUntrackedReposAndExamples()
|
|
|
+function resetExampleRepos() {
|
|
|
+ getUntrackedReposAndExamples()
|
|
|
+ .then(files => Promise.map(files,
|
|
|
+ file => execAsync('rm -r ' + appRoot + '/' + file)
|
|
|
+ // file => console.log('rm -r ' + appRoot + '/' + file)
|
|
|
+ ))
|
|
|
+}
|
|
|
+
|
|
|
+module.exports = resetExampleRepos;
|