modlist.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const fs = require('fs')
  2. /**
  3. * Class used to configure mod launch args.
  4. */
  5. export class ModList {
  6. /**
  7. * Construct a ModList.
  8. *
  9. * @param {String} repositoryRoot - the base path of the mod locations.
  10. * @param {Array.<String>} modRef - array containing the mod artifact ids.
  11. * @param {String} parentList - parent ModList file path, null if none.
  12. */
  13. constructor(repositoryRoot, modRef, parentList){
  14. if(!arguments.length){
  15. this.repositoryRoot = ''
  16. this.modRef = []
  17. }
  18. this.repositoryRoot
  19. this.modRef = modRef
  20. if(parentList != null) this.parentList = parentList
  21. }
  22. /**
  23. * Exports a ModList object to the specified file path.
  24. *
  25. * @param {ModList} modList - the ModList object to export.
  26. * @param {String} filePath - desired filepath.
  27. * @returns {Promise.<String>} - a promise which resolves FML modList argument.
  28. */
  29. static exportModList(modList, filePath){
  30. return new Promise(function(resolve, reject){
  31. fs.writeFile(filePath, JSON.stringify(modList), (err) => {
  32. if(err){
  33. reject(err.message)
  34. }
  35. resolve('--modListFile ' + filePath)
  36. })
  37. })
  38. }
  39. /**
  40. *
  41. * @param {Object} distro - the distribution index.
  42. */
  43. static generateModList(distro){
  44. }
  45. }