Skip to content

Instantly share code, notes, and snippets.

@egoarka
Last active November 18, 2018 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egoarka/d137d121606de25bf9838ed558062e4c to your computer and use it in GitHub Desktop.
Save egoarka/d137d121606de25bf9838ed558062e4c to your computer and use it in GitHub Desktop.
collect all dependencies from js file
const s = process.argv[2];
const searchString = (string, pattern) =>
string
.match(new RegExp(pattern.source, pattern.flags))
.map(match => new RegExp(pattern.source, pattern.flags).exec(match));
console.log(
searchString(s, /require\(\'(.*)'\)/gi)
.map(([_, r]) => r)
.join(' '),
);
cat file | xargs -0 -I _ node collect.js _
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment