geelen / shellac

Coat your shell scripts in something a bit more beautiful
MIT License
156 stars 4 forks source link

Exit blocks (see #4) #5

Closed geelen closed 3 years ago

geelen commented 3 years ago

This adds the exits block to a shellac block:

await shellac`
  exits {
    $ echo "this gon fail" >&2; false
  }
  stderr >> ${(stderr) => expect(stderr).toBe('this gon fail')}
  exitcode >> ${(exitcode) => expect(exitcode).toBe(1)}
`

Since you often want to verify a particular exitcode, the exits(num) callback is given:

await shellac`
  exits(1) {
    $ echo "this gon fail" >&2; false
  }
  stderr >> ${(stderr) => expect(stderr).toBe('this gon fail')}
`

Within an exits block, every line is expected to error (with the specific code, if given).