MCPcopy Create free account
hub / github.com/IceClusters/icmysql / UpdateScript

Function UpdateScript

src/utils/Updater.js:33–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31}
32
33async function UpdateScript() {
34 const ignoreFiles = ["config.js"];
35 const downloadUrl = "https://github.com/IceClusters/icmysql/archive/refs/heads/develop.zip";
36 const extractPath = path.join(GetResourcePath(global.resourceName));
37 const downloadPath = path.join(extractPath, "icmysql.zip");
38 const download = await axios({
39 method: 'get',
40 url: downloadUrl,
41 responseType: 'stream'
42 });
43 const writer = fs.createWriteStream(downloadPath);
44 download.data.pipe(writer);
45 await new Promise((resolve, reject) => {
46 writer.on('finish', resolve);
47 writer.on('error', reject);
48 });
49 if (!fs.existsSync(extractPath)) {
50 await CreateDirRecursive(extractPath)
51 }
52 try {
53 await extract(downloadPath, { dir: path.resolve(extractPath, '..') });
54 const newFolderPath = extractPath.replace("icmysql", "icmysql-old");
55 const oldFolderPath = extractPath.replace("icmysql", "icmysql-develop");
56 await fs.promises.copyFile(path.join(extractPath, "config.js"), path.join(oldFolderPath, "config.js"));
57 await fs.promises.rename(extractPath, newFolderPath);
58 await fs.promises.rename(path.join(path.resolve(extractPath, '..'), "icmysql-develop"), extractPath);
59 } catch (err) {
60 ParseError("Error updating resource", [err]);
61 }
62}
63
64async function CheckVersion() {
65 GetVersion().then(async function (version) {

Callers 1

CheckVersionFunction · 0.85

Calls 2

CreateDirRecursiveFunction · 0.85
ParseErrorFunction · 0.85

Tested by

no test coverage detected