Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Add comment #13

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 61 additions & 20 deletions NodeInstaller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,72 @@ var dver = "0.0.280";

var asar = require('asar');
var wrench = require('wrench');
var fs = require('fs');
var fs = require('fs-promise');
var readline = require('readline');
var util = require('util');
var path = require('path');

var _discordPath;
var _appFolder = "\\app";
var _appArchive = "\\app.asar";
var _packageJson = _appFolder + "\\package.json";
var _index = _appFolder + "\\app\\index.js";
var _discordPath = path.join(process.env.LOCALAPPDATA, `/Discord/app-${dver}`, "/resources");
var _appPath = path.join(_discordPath, '/app');
var _betterDiscordPath = path.join(_appPath, '/node_modules', '/BetterDiscord');
var _packageJson = path.resolve('../app/package.json');
var _index = path.resolve('../app/app/index.js');

function install() {
console.log(`Looking for discord resources at: ${_discordPath}`);

fs.stat(_discordPath)
.then(() => {
console.log(
`Discord resources found at: ${_discordPath}`
);

fs.stat(_appPath)
.then(() => {
console.log(`Deleting ${_appPath} folder.`);
return fs.rmdir(_appPath)
.then(() => {
console.log(`Deleted ${_appPath} folder.`);
});
})
.catch(err => {
console.log("App path not found, continuing...");
})

fs.stat(_betterDiscordPath)
.then(() => {
console.log(`Deleting ${_betterDiscordPath} folder.`);

return fs.rmdir(_betterDiscordPath)
.then(() => {
console.log(`Deleted ${_betterDiscordPath} folder.`);
});
})
.catch(err => {
console.log("Old better discord installation not found, continuing...");
})
})
.catch(err => {
console.log("Unable to locate discord installation, stopping...");
process.exit();
});
/*
fs.stat(_discordPath, function(err, stats) {
if(err) {
console.log(err);
process.exit();
}

_discordPath = process.env.LOCALAPPDATA + "\\Discord\\app-"+dver+"\\resources";
console.log("Looking for discord resources at: " + _discordPath);

fs.exists(_discordPath, function(exists) {

if(exists) {
console.log("Discord resources found at: " + _discordPath + "\nLooking for app folder");
console.log(
`Discord resources found at: ${_discordPath}
Looking for app folder...`
);

if(fs.existsSync(_discordPath + _appFolder)) {
console.log("Deleting " + _discordPath + _appFolder + " folder.");
wrench.rmdirSyncRecursive(_discordPath + _appFolder);
console.log("Deleted " + _discordPath + _appFolder + " folder.");
}
if(fs.statSync(_discordPath + _appFolder)) {
console.log("Deleting " + _discordPath + _appFolder + " folder.");
wrench.rmdirSyncRecursive(_discordPath + _appFolder);
console.log("Deleted " + _discordPath + _appFolder + " folder.");
}

if(fs.existsSync(_discordPath + "\\node_modules\\BetterDiscord")) {
console.log("Deleting " + _discordPath + "\\node_modules\\BetterDiscord" + " folder.");
Expand Down Expand Up @@ -97,7 +138,7 @@ function install() {
}

});

*/
}

function init() {
Expand All @@ -107,7 +148,7 @@ function init() {

var rl = readline.createInterface({ input: process.stdin, output: process.stdout });

rl.question("The following directories will be deleted if they exists: discorpath\\app, discordpath\\node_modules\\BetterDiscord, is this ok? Y/N", function(answer) {
rl.question("The following directories will be deleted if they exists: discorpath\\app, discordpath\\node_modules\\BetterDiscord, is this ok? Y/N \n", function(answer) {

var alc = answer.toLowerCase();

Expand Down
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "app/index.js",
"private": true,
"dependencies": {
"react": "^0.13.0",
"betterdiscord": "^0.1.2"
"react": "0.14.0",
"betterdiscord": "^0.1.2"
}
}
2 changes: 2 additions & 0 deletions betterdiscord.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// Remove this

module.exports = require('./lib/BetterDiscord');
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@
"version": "0.1.2",
"homepage": "https://github.com/Jiiks/BetterDiscordApp",
"license": "MIT",
"main": "betterdiscord.js"
"main": "betterdiscord.js",
"scripts": {
"start": "node NodeInstaller/index.js"
},
"dependencies": {
"asar": "^0.8.0",
"fs-promise": "^0.3.1",
"wrench": "^1.5.8"
}
}