diff options
author | 2020-09-22 20:56:48 +0200 | |
---|---|---|
committer | 2020-09-22 19:56:48 +0100 | |
commit | 6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch) | |
tree | 9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /scripts/verify.js | |
parent | Updated logos for Outlook/OWA (diff) | |
download | ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.gz ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.zst ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.zip |
Unpack recipes and update recipes icons (#292)
Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'scripts/verify.js')
-rw-r--r-- | scripts/verify.js | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/scripts/verify.js b/scripts/verify.js deleted file mode 100644 index e2124e6..0000000 --- a/scripts/verify.js +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | /** | ||
2 | * Verify packaged recipe to match uncompressed recipe | ||
3 | */ | ||
4 | const targz = require('targz'); | ||
5 | const fs = require('fs-extra'); | ||
6 | const dircompare = require('dir-compare'); | ||
7 | const path = require('path'); | ||
8 | |||
9 | // Helper: Compress src folder into dest file | ||
10 | const decompress = (src, dest) => new Promise((resolve, reject) => { | ||
11 | targz.decompress({ | ||
12 | src, | ||
13 | dest, | ||
14 | tar: { | ||
15 | // Don't unpackage .DS_Store files | ||
16 | ignore: function(name) { | ||
17 | return path.basename(name) === '.DS_Store' | ||
18 | } | ||
19 | }, | ||
20 | }, (err) => { | ||
21 | if (err) { | ||
22 | reject(err); | ||
23 | } else { | ||
24 | resolve(dest); | ||
25 | } | ||
26 | }); | ||
27 | }); | ||
28 | |||
29 | if (!process.argv[2]) { | ||
30 | console.log('Usage: yarn verify <recipe>'); | ||
31 | return; | ||
32 | } | ||
33 | |||
34 | // Let us work in an async environment | ||
35 | (async () => { | ||
36 | const recipe = process.argv[2]; | ||
37 | |||
38 | const compressedRecipe = path.join(__dirname, '../', 'archives', `${recipe}.tar.gz`); | ||
39 | const uncompressedRecipe = path.join(__dirname, '../', 'uncompressed', recipe); | ||
40 | const tempUncompressed = path.join(__dirname, `uncompressed/`); | ||
41 | |||
42 | // Check that recipe exists | ||
43 | if (!await fs.pathExists(compressedRecipe) || !await fs.pathExists(uncompressedRecipe)) { | ||
44 | console.log(`Error: Recipe does not exist.`); | ||
45 | return; | ||
46 | } | ||
47 | |||
48 | if (await fs.pathExists(tempUncompressed)) { | ||
49 | await fs.remove(tempUncompressed); | ||
50 | } | ||
51 | await fs.mkdir(tempUncompressed); | ||
52 | |||
53 | // Package to uncompressed recipe to .tar.gz | ||
54 | console.log(`Decompressing...`); | ||
55 | await decompress(compressedRecipe, tempUncompressed); | ||
56 | |||
57 | // Compare directories | ||
58 | const compare = dircompare.compareSync(uncompressedRecipe, tempUncompressed, { | ||
59 | compareContent: true, | ||
60 | }); | ||
61 | |||
62 | if (compare.same) { | ||
63 | console.log('✓ Compressed and uncompressed files are equal'); | ||
64 | } else { | ||
65 | console.log('❌ Compressed and uncompressed files are NOT equal'); | ||
66 | } | ||
67 | |||
68 | // Remove temporary compressed file | ||
69 | await fs.remove(tempUncompressed); | ||
70 | })(); \ No newline at end of file | ||