-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_integrity.js
59 lines (51 loc) · 1.77 KB
/
check_integrity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const fs = require('fs')
const { hashElement } = require('folder-hash')
async function main(argv) {
try {
const hashOut = './lib/my_hash.js'
const path = 'node_modules/golos-lib-js'
const res = await hashElement(path, {
files: {
exclude: [
path + '/lib/my_hash.js',
path + '/dist/golos.min.js.gz',
path + '/dist/golos-tests.min.js.gz',
path + '/dist/stats.html',
// These not including when NPM publishes
'.npmrc',
'.babelrc',
'.gitignore',
'.npmignore',
'yarn.lock',
],
matchBasename: true,
matchPath: true,
},
folders: {
exclude: [
'node_modules',
path + '/src',
path + '/examples'
],
matchPath: true,
ignoreRootName: true
}
})
console.log(res.children)
//console.log(res.children.filter(o => o.name === 'lib')[0].children.filter(o => o.name === 'auth')[0].children)
console.log('LIBRARY HASH IS', res.hash)
if (argv[2] === '--save') {
let json = 'node_modules/golos-lib-js/package.json'
json = fs.readFileSync(json, 'utf8')
json = JSON.parse(json)
const appPath = 'app/JsLibHash.json'
let data = {}
data.version = json.version
data.hash = res.hash
fs.writeFileSync(appPath, JSON.stringify(data))
}
} catch (err) {
console.error('LIBRARY HASH FAILED:', err)
}
}
main(process.argv)