Skip to content

Instantly share code, notes, and snippets.

@JhonatanHern
Created March 12, 2020 22:28
Show Gist options
  • Save JhonatanHern/ca37a993194049d8096ef47684d2990f to your computer and use it in GitHub Desktop.
Save JhonatanHern/ca37a993194049d8096ef47684d2990f to your computer and use it in GitHub Desktop.
const fs = require('fs').promises
const moduleFolders = ['defs', 'lib', 'rpc', 'storage', 'storage_consts']
const findOffenders = async fileArray => {
const offenders = []
for (let index = 0; index < fileArray.length; index++) {
const file = fileArray[index]
const data = (await fs.readFile(file)).toString()
if (data[0]!=='/'){
offenders.push(file)
}
}
return offenders
}
const getFileArray = () => {
return new Promise(async (succ, err) => {
const files = []
const folders = await fs.readdir('lib')
for (let index = 0; index < folders.length; index++) {
const folder = folders[index];
for (let index = 0; index < moduleFolders.length; index++) {
const modFolder = moduleFolders[index];
try{
const exists = await fs.stat('lib/'+folder + '/' + modFolder)
if(exists){
files.push('lib/'+folder + '/' + modFolder + '/src/lib.rs')
}
}catch(e){}
}
}
succ(files)
})
}
const asyncMain = async () => {
const files = await getFileArray()
const offenders = await findOffenders(files)
console.log('offenders:')
offenders.forEach(off=>{
console.log(off)
})
}
asyncMain()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment