Skip to content

Commit 1e93bcf

Browse files
committed
need to run npm i to run properly
1 parent a3b7684 commit 1e93bcf

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

assets/plugins/update.js

+39-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { command } = require("../../lib/");
44
const { exec } = require("child_process");
55
const simplegit = require("simple-git");
66
const git = simplegit();
7+
var branch = config.BRANCH;
78

89
command(
910
{
@@ -15,7 +16,7 @@ command(
1516
async (message, match) => {
1617
prefix = message.prefix;
1718
await git.fetch();
18-
var branch = config.BRANCH;
19+
1920
var commits = await git.log([branch + "..origin/" + branch]);
2021
if (match === "now") {
2122
if (commits.total === 0) {
@@ -25,13 +26,33 @@ command(
2526
);
2627
}
2728
await message.sendMessage(message.jid, "*Updating...*");
28-
await exec("git pull origin "+config.BRANCH, async (err, stdout, stderr) => {
29-
if (err) {
30-
return await message.sendMessage(message.jid, "```" + stderr + "```");
29+
await exec(
30+
"git pull origin " + config.BRANCH,
31+
async (err, stdout, stderr) => {
32+
if (err) {
33+
return await message.sendMessage(
34+
message.jid,
35+
"```" + stderr + "```"
36+
);
37+
}
38+
await message.sendMessage(message.jid, "*Restarting...*");
39+
let dependancy = await updatedDependencies();
40+
if (dependancy) {
41+
exec(
42+
"npm install && pm2 restart " + PROCESSNAME,
43+
async (err, stdout, stderr) => {
44+
if (err) {
45+
return await message.sendMessage(
46+
message.jid,
47+
"```" + stderr + "```"
48+
);
49+
}
50+
await message.sendMessage(message.jid, "*Restarting...*");
51+
}
52+
);
53+
}
3154
}
32-
await message.sendMessage(message.jid, "*Restarting...*");
33-
await exec("pm2 restart " + PROCESSNAME);
34-
});
55+
);
3556
} else {
3657
if (commits.total === 0) {
3758
return await message.sendMessage(
@@ -52,3 +73,14 @@ command(
5273
}
5374
}
5475
);
76+
77+
async function updatedDependencies() {
78+
try {
79+
const diff = await git.diff([`${branch}..origin/${branch}`]);
80+
const hasDependencyChanges = diff.includes('"dependencies":');
81+
return hasDependencyChanges;
82+
} catch (error) {
83+
console.error("Error occurred while checking package.json:", error);
84+
return false;
85+
}
86+
}

assets/plugins/ytdl.js

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ command(
3535
},
3636
"audio"
3737
);
38+
3839
}
3940
);
4041

0 commit comments

Comments
 (0)