Added drag/drop functionality to the add mods button.

You can now drag one or more files onto the add mods button in order to add them to the mods directory. Only jar, litemod, and zip files will be moved.
Changed eslint to use a single configuration file, with overrides for the UI scripts.
Now using fs-extra, replace usages of rimraf and mkdirp with fs-extra functions.
This commit is contained in:
Daniel Scalzi
2018-12-01 08:20:42 -05:00
parent d9c9b32446
commit d779eacf61
11 changed files with 170 additions and 143 deletions

View File

@@ -1,5 +1,4 @@
const fs = require('fs')
const mkpath = require('mkdirp')
const fs = require('fs-extra')
const path = require('path')
const { shell } = require('electron')
@@ -16,9 +15,7 @@ const DISABLED_EXT = '.disabled'
* @param {string} modsDir The path to the mods directory.
*/
exports.validateModsDir = function(modsDir) {
if(!fs.existsSync(modsDir)) {
mkpath.sync(modsDir)
}
fs.ensureDirSync(modsDir)
}
/**
@@ -66,6 +63,22 @@ exports.scanForDropinMods = function(modsDir, version) {
return modsDiscovered
}
/**
* Add dropin mods.
*
* @param {FileList} files The files to add.
* @param {string} modsDir The path to the mods directory.
*/
exports.addDropinMods = function(files, modsdir) {
for(let f of files) {
if(MOD_REGEX.exec(f.name) != null) {
fs.moveSync(f.path, path.join(modsdir, f.name))
}
}
}
/**
* Delete a drop-in mod from the file system.
*