fix the setup script to correctly install node_modules dependencies

pull/104/head
dperolio 2 years ago
parent 02b4c50456
commit cf40e1d834
No known key found for this signature in database
GPG Key ID: 4191689562D51409

File diff suppressed because one or more lines are too long

@ -239,10 +239,10 @@ async function getDiscordAppPath () {
* Used in this script for installing Node package dependencies. * Used in this script for installing Node package dependencies.
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
function installDependencies () { async function installDependencies () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const command = spawn('npm', [ 'install', '--only=production', '--silent' ], { const command = spawn('npm', [ 'install', '--only=production', '--silent' ], {
cwd: join(__dirname, '..', '..', '..'), cwd: join(__dirname, '..'),
stdio: 'inherit', stdio: 'inherit',
shell: true shell: true
}); });
@ -288,11 +288,11 @@ async function ensureDependencies () {
} }
} }
const missingDependenciesMessage = `${missingDependencies.length} missing`; const missingDependenciesMessage = missingDependencies.length && `${missingDependencies.length} missing`;
const outdatedDependenciesMessage = `${outdatedDependencies.length} outdated`; const outdatedDependenciesMessage = outdatedDependencies.length && `${outdatedDependencies.length} outdated`;
if (missingDependencies.length || outdatedDependencies.length) { if (missingDependenciesMessage || outdatedDependenciesMessage) {
warn(`Found ${[ missingDependenciesMessage, outdatedDependenciesMessage ].filter(message => message)} ${missingDependencies.length + outdatedDependencies.length > 1 ? 'packages' : 'package'}. Resolving...`); warn(`Found ${[ missingDependenciesMessage, outdatedDependenciesMessage ].filter(Boolean).join(' and ')} ${missingDependencies.length + outdatedDependencies.length > 1 ? 'packages' : 'package'}. Resolving...`);
} }
/** /**
@ -310,9 +310,10 @@ async function ensureDependencies () {
/** /**
* Uninjects Vizality from Discord. * Uninjects Vizality from Discord.
* @param {path} discordAppPath Discord app path * @param {path} discordAppPath Discord app path
* @param {boolean} vizality Whether or not the client mod is known to be Vizality
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async function uninject (discordAppPath) { async function uninject (discordAppPath, vizality = true) {
/** /**
* Check for a valid Discord app directory. * Check for a valid Discord app directory.
*/ */
@ -334,7 +335,7 @@ async function uninject (discordAppPath) {
*/ */
await rm(discordAppPath, { recursive: true, force: true }); await rm(discordAppPath, { recursive: true, force: true });
brand('-----------------------------------------------'); brand('-----------------------------------------------');
brand('Vizality has been uninjected.'); brand(`${vizality ? 'Vizality' : 'Client modification'} has been uninjected.`);
brand('-----------------------------------------------'); brand('-----------------------------------------------');
} }
@ -360,7 +361,7 @@ async function inject (discordAppPath) {
]); ]);
if (responses.action.includes('Yes')) { if (responses.action.includes('Yes')) {
return reinject(discordAppPath); return reinject(discordAppPath, false);
} }
warn('Vizality injection canceled. Now exiting...'); warn('Vizality injection canceled. Now exiting...');
@ -388,10 +389,11 @@ async function inject (discordAppPath) {
/** /**
* Reinjects Vizality into Discord. * Reinjects Vizality into Discord.
* @param {path} discordAppPath Discord app path * @param {path} discordAppPath Discord app path
* @param {boolean} vizality Whether or not the client mod is known to be Vizality
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async function reinject (discordAppPath) { async function reinject (discordAppPath, vizality = true) {
await uninject(discordAppPath); await uninject(discordAppPath, vizality);
await inject(discordAppPath); await inject(discordAppPath);
} }

Loading…
Cancel
Save