From 18a90ed998ca487a92127059517c5129dff46754 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Fri, 11 Aug 2023 13:41:01 +1000 Subject: [PATCH] Hide terminal window when spawning child process --- src/client.ts | 2 +- src/commands/dev.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client.ts b/src/client.ts index 4a0cd46..d286500 100644 --- a/src/client.ts +++ b/src/client.ts @@ -102,7 +102,7 @@ export default class TClient extends Client { socketTimeoutMS: 30000, tls: false, family: 4 - }).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch(err=>{console.error(this.logTime(), `Failed to connect to MongoDB\n${err}`); exec('pm2 stop Daggerbot')}) + }).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch(err=>{console.error(this.logTime(), `Failed to connect to MongoDB\n${err}`); exec('pm2 stop Daggerbot', {windowsHide:true})}) this.login(this.tokens.main); for await (const file of readdirSync('dist/events')){ //console.log('EVENTS:', file) diff --git a/src/commands/dev.ts b/src/commands/dev.ts index 5f79a6e..10cc796 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -75,12 +75,12 @@ export default { deletion: await octokit.repos.getCommit(githubRepo).then(x=>x.data.stats.deletions.toLocaleString('en-US')).catch((err:Error)=>err.message) } }; - exec('git pull',(err:Error,stdout)=>{ + exec('git pull',{windowsHide:true},(err:Error,stdout)=>{ if (err) clarkson.edit(`\`\`\`${removeUsername(err.message)}\`\`\``) else if (stdout.includes('Already up to date')) clarkson.edit('I am already up to date with the upstream repository.') - else clarkson.edit('Compiling TypeScript files...').then(()=>exec('yarn tsc', (err:Error)=>{ + else clarkson.edit('Compiling TypeScript files...').then(()=>exec('yarn tsc', {windowsHide:true}, (err:Error)=>{ if (err) clarkson.edit(`\`\`\`${removeUsername(err.message)}\`\`\``) - else clarkson.edit(`[Commit:](<${github.fetchCommit.url}>) **${github.fetchCommit.msg}**\nCommit author: **${github.fetchCommit.author}**\n\n__Commit changes__\nTotal: **${github.fetchChanges.total}**\nAdditions: **${github.fetchChanges.addition}**\nDeletions: **${github.fetchChanges.deletion}**\n\nSuccessfully compiled TypeScript files into JavaScript!\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot')) + else clarkson.edit(`[Commit:](<${github.fetchCommit.url}>) **${github.fetchCommit.msg}**\nCommit author: **${github.fetchCommit.author}**\n\n__Commit changes__\nTotal: **${github.fetchChanges.total}**\nAdditions: **${github.fetchChanges.addition}**\nDeletions: **${github.fetchChanges.deletion}**\n\nSuccessfully compiled TypeScript files into JavaScript!\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot', {windowsHide:true})) })) }); }, @@ -122,9 +122,9 @@ export default { }, restart: async()=>{ const i = await interaction.reply({content: 'Compiling TypeScript files...', fetchReply: true}); - exec('yarn tsc',(err:Error)=>{ + exec('yarn tsc',{windowsHide:true},(err:Error)=>{ if (err) i.edit(`\`\`\`${removeUsername(err.message)}\`\`\``) - else i.edit(`Successfully compiled TypeScript files into JavaScript!\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot')) + else i.edit(`Successfully compiled TypeScript files into JavaScript!\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot', {windowsHide:true})) }) }, file: ()=>interaction.reply({files:[`./src/database/${interaction.options.getString('name')}.json`]}).catch(()=>'Filesize is too large, upload cancelled.')