arma-server-web-admin/lib/mods.js

44 lines
893 B
JavaScript
Raw Normal View History

var events = require('events')
var fs = require('fs.extra')
2020-12-26 12:56:59 +00:00
var glob = require('glob')
var path = require('path')
var Mods = function (config) {
this.config = config
this.mods = []
}
Mods.prototype = new events.EventEmitter()
2015-07-22 18:16:30 +00:00
Mods.prototype.delete = function (mod, cb) {
var self = this
2015-07-22 18:16:30 +00:00
fs.rmrf(path.join(this.config.path, mod), function (err) {
cb(err)
if (!err) {
self.updateMods()
}
})
}
2015-07-22 18:16:30 +00:00
Mods.prototype.updateMods = function () {
var self = this
2021-06-16 12:32:41 +00:00
glob('**/{@*,csla,gm,vn}/addons', { cwd: self.config.path }, function (err, files) {
if (err) {
console.log(err)
} else {
2020-12-26 12:56:59 +00:00
var mods = files.map(function (file) {
2017-02-21 19:22:28 +00:00
return {
2020-12-26 12:56:59 +00:00
// Find actual parent mod folder from addons folder
name: path.join(file, '..')
}
})
2017-02-21 19:22:28 +00:00
self.mods = mods
self.emit('mods', mods)
2015-02-04 23:42:18 +00:00
}
})
}
2015-02-01 04:01:50 +00:00
module.exports = Mods