dotcore64 / gulp-xml-transformer

Gulp plugin for transforming xml content

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to indicate that a path is optional?

grofit opened this issue · comments

commented

Currently I am trying to use this as part of a build script where I want to basically read some environmental config files and for any correlating appSetting or connectionString nodes in a web/app.config file replace them.

The problem is there will probably be a lot of environmental variables which are not going to be in the web.config files and currently it reports an error that it cannot find the path, so is there a way for me to build all possible paths but indicate that if it doesn't find a match just skip it and continue?

== Edit

It seems like https://github.com/perrin4869/gulp-xml-transformer/blob/master/src/transformers.js#L21 could be updated in some way to basically check for an isRequired property or something, but let me know your thoughts on it.

An isRequired option sounds great! Not sure what the default value for it should be though. For compatibility's sake, maybe true would be better... but I have a feeling that false makes more sense.
A PR would be appreciated :D

commented

I am not that fussed about the naming, as mandatory or other words are just as applicable, and I am happy for it to default to true like you say, just any way to give it a way to ignore failing paths, as then there is also the discussion on should the ignore happen per path or at config root, again not fussed either way.

As far as PR I would love to but I am currently up against it for a release, had to drop the xml transform for the moment and look at something else, but if I get time to play some tech debt I will look back into this, but I wouldn't see that as a guarantee it will be done anytime soon.

commented

Did convince team to give me 30 mins to try and get it fixed, but problem is I cannot build it due to lint not liking windows CRLF stuff and also dont have python installed and as mad as it may sound I dont have admin rights on this PC so cannot get the xml thingy compiled.

I did however prototype the change, but haven't put a test in:
https://gist.github.com/grofit/a18b872245f5b217c9125faee658181f

If you get time have a quick look over and if you are happy enough with it and can put a test in to verify it matches the behaviour you can put it into a commit etc, otherwise it will be next week before I will be able to look at it again.

@grofit thank you for your input!
I just pushed 33a7ed8
After the Travis passes my tests I'll publish a new version to npm.
Tell me if this solves your problem!

Released in 1.3.0

commented

Thanks for sorting it :)