Last active
October 1, 2015 16:24
-
-
Save MadLittleMods/7366e2797eb96da5857c to your computer and use it in GitHub Desktop.
Removes files that are missing from the repo. `node svn-remove-missing.js`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var exec = require('child_process').exec; | |
| var svnRemoveFile = function(filePath) { | |
| var child = exec('svn rm "' + filePath + '" --force', function(err, stdout, stderr) { | |
| /* * / | |
| if(err) { | |
| console.log(err); | |
| } | |
| if(stderr) { | |
| console.log(stderr); | |
| } | |
| /* */ | |
| console.log(stdout); | |
| }); | |
| child.on('exit', function (exitCode) { | |
| if(exitCode !== 0) { | |
| console.log(`Child exited with code: ${exitCode}`); | |
| } | |
| process.exitCode = 0; | |
| }); | |
| }; | |
| console.log('Starting to remove missing files from SVN repo'); | |
| exec('svn st | grep ^!', function(err, stdout, stderr) { | |
| if(err) { | |
| console.log(err); | |
| } | |
| if(stderr) { | |
| console.log(stderr); | |
| } | |
| var missingFilePaths = stdout | |
| .split(/\n/) | |
| .map(function(item) { | |
| var matches = item.match(/!\s*(.*?)$/); | |
| if(matches && matches.length >= 1) { | |
| return matches[1]; | |
| } | |
| return false; | |
| }) | |
| .filter(function(path) { | |
| return path; | |
| }); | |
| missingFilePaths.forEach(function(filePath) { | |
| svnRemoveFile(filePath); | |
| }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment