node.jsshellnpmpackage.json

What is the difference between using ; and && in package.json scripts?


What is the difference between using ; and && in package.json scripts?

For example the Lit Element Typescript Starter Project has this script:

"checksize": "rollup -c ; cat my-element.bundled.js | gzip -9 | wc -c ; rm my-element.bundled.js"
  },

What effect does the ; have?


Solution

  • That's actually shellscript that's being executed and has nothing to do with javascript.

    Difference here between && and ; is the failure tolerance:

    command1 ; command2

    If command1 fails, command2 will still be executed.

    command1 && command2

    Here if command1 fails, command2 will not be executed.