Search code examples
javascriptlinuxbashunixlerna

How can I perform a npm run test in a lerna exec command?


how to execute a npm run test if the condition is true? please check the code below thanks.

lerna exec --concurrency 1 --scope=file --  pwd | awk '{ if ($0 ~ /pattern_match/) {npm run test} }'

$0 = file directories.

Solution

  • Try

    lerna exec --concurrency 1 --scope=file --  pwd | grep '<pattern match>' && npm run test
    

    Demo :

    $echo asd  |  grep [0-9] && echo "Yes" 
    $echo 123  |  grep [0-9] && echo "Yes" 
    123
    Yes
    $