ChiefOfGxBxL / WC3MapTranslator

Translate war3map ⇄ json formats for WarCraft III .w3x maps
https://www.npmjs.com/package/wc3maptranslator
MIT License
73 stars 31 forks source link

Return object from each translator #4

Closed ChiefOfGxBxL closed 6 years ago

ChiefOfGxBxL commented 7 years ago

Remove the .write() method in each translator and simply return an object: { errors: [], result: }. Writing the files should be left to the implementing program.

ChiefOfGxBxL commented 6 years ago

Refactor the .write() method to return an array of warnings and errors, and the buffer. A separate file will check for warnings and errors and handle them accordingly. The buffer will be written to a logical path. This will also help reduce the code repetition that Code Climate is reporting.

ChiefOfGxBxL commented 6 years ago

Get rid of the .write() method and make the translator simply a function that returns an object:

{
  warnings: [],
  errors: [],
  result: ...
}

This way the file system code is logically separated from the translation. Plus, translation may be desired and writing its result to a file may not. Translation and file system should really be decoupled.