mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-08-28 20:14:37 -05:00
Support updating private code in /updateserver (#7183)
This commit is contained in:
@@ -735,7 +735,7 @@ export const commands: ChatCommands = {
|
||||
|
||||
async updateserver(target, room, user, connection) {
|
||||
if (!this.canUseConsole()) return false;
|
||||
|
||||
const isPrivate = toID(target) === 'private';
|
||||
if (Monitor.updateServerLock) {
|
||||
return this.errorReply(`/updateserver - Another update is already in progress (or a previous update crashed).`);
|
||||
}
|
||||
@@ -746,7 +746,7 @@ export const commands: ChatCommands = {
|
||||
this.stafflog(`$ ${command}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
child_process.exec(command, {
|
||||
cwd: __dirname,
|
||||
cwd: `${__dirname}/../../${isPrivate ? Config.privatecodepath || '../main-private/' : ``}`,
|
||||
}, (error, stdout, stderr) => {
|
||||
let log = `[o] ${stdout}[e] ${stderr}`;
|
||||
if (error) log = `[c] ${error.code}\n${log}`;
|
||||
@@ -757,13 +757,13 @@ export const commands: ChatCommands = {
|
||||
};
|
||||
|
||||
this.sendReply(`Fetching newest version...`);
|
||||
this.addGlobalModAction(`${user.name} used /updateserver`);
|
||||
this.addGlobalModAction(`${user.name} used /updateserver ${isPrivate ? `private` : `public`}`);
|
||||
|
||||
let [code, stdout, stderr] = await exec(`git fetch`);
|
||||
if (code) throw new Error(`updateserver: Crash while fetching - make sure this is a Git repository`);
|
||||
if (!stdout && !stderr) {
|
||||
if (!isPrivate && !stdout && !stderr) {
|
||||
this.sendReply(`There were no updates.`);
|
||||
[code, stdout, stderr] = await exec('node ../../build');
|
||||
[code, stdout, stderr] = await exec('node ./build');
|
||||
if (stderr) {
|
||||
return this.errorReply(`Crash while rebuilding: ${stderr}`);
|
||||
}
|
||||
@@ -815,11 +815,13 @@ export const commands: ChatCommands = {
|
||||
await exec(`git stash pop`);
|
||||
this.sendReply(`FAILED, old changes restored.`);
|
||||
}
|
||||
[code, stdout, stderr] = await exec('node ../../build');
|
||||
if (stderr) {
|
||||
return this.errorReply(`Crash while rebuilding: ${stderr}`);
|
||||
if (!isPrivate) {
|
||||
[code, stdout, stderr] = await exec('node ./build');
|
||||
if (stderr) {
|
||||
return this.errorReply(`Crash while rebuilding: ${stderr}`);
|
||||
}
|
||||
this.sendReply(`Rebuilt.`);
|
||||
}
|
||||
this.sendReply(`Rebuilt.`);
|
||||
Monitor.updateServerLock = false;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user