0

If I have an asynchronous function foo = async function (){...}, I can find all files that call that function like so

grep -r 'foo' .
./f1: return await foo ();
./f2: return await foo ();
./f3: return foo ();

I can also find all the files that call it correctly through the use of the await command like so

grep -r 'await\s*foo' .
./f1: return await foo ();
./f2: return await foo ();

But how do I find the all the files that call it incorrectly without the use of the await command?

Note: Assume that I am only calling asynchronous functions through the await command and I don't use .then or capture the promise into a variable and call await on it later

puk
  • 15,530
  • 28
  • 107
  • 187

1 Answers1

0

I found a solution in a related SO answer here

Simply use pipes and the -v flag to negate, like so

grep -r 'foo' . | grep -v 'await'
puk
  • 15,530
  • 28
  • 107
  • 187