Skip to content

Commit

Permalink
add duplicate check to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
saturn-network committed Oct 30, 2019
1 parent e7ac8eb commit bb312c0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"test": "node test.js"
},
"repository": "[email protected]:saturn-network/assets.git",
"license": "MIT"
"license": "MIT",
"dependencies": {
"lodash": "^4.17.15"
}
}
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
'use strict';
const _ = require('lodash')

function ensureNoDuplicates(arr) {
let allAddresses = _.map(arr, 'address')
let lowerCaseAddys = _.map(allAddresses, x => x.toLowerCase())
let unique = _.uniq(lowerCaseAddys)
if (unique.length !== lowerCaseAddys.length) {
throw new Error('Duplicates detected!')
}
}

try {
let eth = require('./eth/tokens.json')
let etc = require('./etc/tokens.json')
console.log('asset.json is valid!')

ensureNoDuplicates(eth)
ensureNoDuplicates(etc)

process.exit(0)
} catch(e) {
console.error(e)
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


lodash@^4.17.15:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==

0 comments on commit bb312c0

Please sign in to comment.