Created
September 8, 2014 17:58
-
-
Save kimmellj/d6f98861a95a2e169e5d to your computer and use it in GitHub Desktop.
Demandware Pipeline Name Parser
This file contains 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
/** | |
* Parse out the Pipelines created in a Demandware Pipeline File | |
* | |
* This script requires the node-xml2js library, npm install npm install xml2js | |
* | |
* To call: node index.js /some/path/to/the/desired/file/pipelines.xml | |
* | |
* @param File Name, the first and only argument to this script is a path to the file to parse | |
*/ | |
var parseString = require('xml2js').parseString, | |
fs = require('fs'); | |
/** | |
* There are Annoymous branches used by Demandware, we want to filter | |
* these out because they're not useful by themselves | |
*/ | |
var anonRegex = /_ANONYMOUS_/i; | |
/** | |
* Read all of the contents of the supplied file and then parse it | |
*/ | |
fs.readFile(process.argv[2], 'utf8', function (err,data) { | |
if (err) { | |
return console.log(err); | |
} | |
parseString(data, function (err, result) { | |
/** | |
* Pipelines are called Branches in the XML | |
* Let's get them all | |
*/ | |
var branches = result.pipeline.branch; | |
branches.forEach(function(branch){ | |
var baseName = branch['$'].basename; | |
var match = baseName.match(anonRegex); | |
/** | |
* Skip if this branch is Anonymous | |
*/ | |
if (match === null) { | |
console.log(baseName); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment