MCPcopy Index your code
hub / github.com/MALSync/MALSync / main

Function main

webpackConfig/missingPermissions.js:9–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8main();
9async function main() {
10 const lastExtensionPath = path.join(__dirname, '../dist/lastExtension/manifest.json');
11 if (!fs.existsSync(lastExtensionPath)) {
12 console.log('Downloading');
13 mkdirp.sync(path.join(__dirname, '../dist/lastExtension'));
14 await ex(
15 'curl -fsSL https://github.com/MALSync/MALSync/releases/latest/download/webextension.zip -o dist/lastExtension.zip',
16 );
17 console.log('Extracting');
18 try {
19 await ex(`tar -xf dist/lastExtension.zip --directory dist/lastExtension`);
20 } catch (error) {
21 await ex(`unzip -o dist/lastExtension.zip -d dist/lastExtension`);
22 }
23 } else {
24 console.log('Skipping download, manifest found.');
25 }
26
27 const manifest = require('../dist/lastExtension/manifest.json');
28
29 const version = manifest.version;
30 const oldUrls = getUrls(manifest);
31 const descFile = path.join(__dirname, '../src/pages/diffUrls.json');
32 fs.readFile(descFile, 'utf8', function(err, data) {
33 const currentData = JSON.parse(data);
34 const diffUrls = getDiff(oldUrls, currentData[version]);
35 console.log(version, diffUrls);
36 currentData[version] = diffUrls;
37
38 if(Object.keys(currentData).length > 5) {
39 const remove = Object.keys(currentData).slice(0, Object.keys(currentData).length - 5);
40
41 for(const item of remove) {
42 delete currentData[item];
43 }
44 }
45
46 fs.writeFile(descFile, JSON.stringify(currentData, null, 2), 'utf8', function (err) {
47 if (err) throw err;
48 });
49 });
50}
51
52function getDiff(oldUrls, oldDiff) {
53 res = {};

Callers 1

Calls 5

exFunction · 0.85
getUrlsFunction · 0.85
getDiffFunction · 0.85
syncMethod · 0.80
keysMethod · 0.80

Tested by

no test coverage detected