Skip to content

Instantly share code, notes, and snippets.

@chenyong
Created September 11, 2019 08:02
Show Gist options
  • Save chenyong/0fdfc451157516eeb01aa447547d1823 to your computer and use it in GitHub Desktop.
Save chenyong/0fdfc451157516eeb01aa447547d1823 to your computer and use it in GitHub Desktop.
temp script for find out deps
fs = require 'fs'
_ = require 'lodash'
data = JSON.parse fs.readFileSync 'data.text', 'utf8'
dict = data.map (list) ->
[list[0], list[1..].flat() ]
dictObj = {}
dict.forEach (pair) ->
dictObj[pair[0]] = pair[1]
root = 'main.tsx'
grabByRoot = (parent) ->
children = dictObj[parent]
# console.log 'found children', children
if !children?
console.warn "Failed for", parent
else
deepChildren = children.flatMap (child) ->
grabByRoot child
children.concat deepChildren
allFiles = grabByRoot(root)
console.log (_.uniq allFiles).join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment