Last active
March 1, 2018 15:29
-
-
Save stepancar/b50ba890628e9111a8316d6cf66218e5 to your computer and use it in GitHub Desktop.
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
// ДЕЛАЕМ ГОВНО ЧТОБ НЕ БЫЛО ГОВНА | |
const fs = require('fs'); | |
const Path = require('path'); | |
if (!String.prototype.splice) { | |
String.prototype.splice = function(start, delCount, newSubStr) { | |
return this.slice(0, start) + newSubStr + this.slice(start + Math.abs(delCount)); | |
}; | |
} | |
function readDirR(dir) { | |
return (fs.statSync(dir).isDirectory() && !dir.endsWith('wscommontypes10')) | |
? Array.prototype.concat(...fs.readdirSync(dir).map(f => readDirR(Path.join(dir, f)))) | |
: dir; | |
} | |
function deleteFolderRecursive(path) { | |
if (fs.existsSync(path)) { | |
fs.readdirSync(path).forEach(function(file, index){ | |
var curPath = path + "/" + file; | |
if (fs.lstatSync(curPath).isDirectory()) { // recurse | |
deleteFolderRecursive(curPath); | |
} else { // delete file | |
fs.unlinkSync(curPath); | |
} | |
}); | |
fs.rmdirSync(path); | |
} | |
}; | |
const files = readDirR(Path.resolve('./src/main/java')); | |
files.forEach(file => { | |
if (file.endsWith('wscommontypes10')) { | |
return deleteFolderRecursive(file); | |
} | |
if (Path.extname(file) === '.java') { | |
if (file.indexOf('wscommontypes10') !== -1 ) { | |
return fs.unlinkSync(file); | |
} | |
if (file.indexOf('Exception') !== -1 ) { | |
return fs.unlinkSync(file); | |
} | |
let content = fs.readFileSync(file, 'utf8') | |
.replace(new RegExp('src/main/resources/wsdl/', 'g'), '/wsdl/'); | |
if (content.indexOf('MsgWS') !== -1) { | |
const indexOfImport = content.indexOf('import'); | |
content = content | |
.splice(indexOfImport, 0, 'import ru.alfabank.ws.cs.wscommontypes10.exception.*;\n') | |
.replace(/MsgWS/g, 'WS') | |
} | |
fs.writeFileSync(file, content); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment