From 790baae673fd60c36f47b9f9b31c9cf132ba3437 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 19 Aug 2018 03:00:34 -0400 Subject: Expose deno.exit() and add test. --- tools/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tools/util.py') diff --git a/tools/util.py b/tools/util.py index 9e29cf742..b50b754c2 100644 --- a/tools/util.py +++ b/tools/util.py @@ -1,5 +1,6 @@ # Copyright 2018 the Deno authors. All rights reserved. MIT license. import os +import re import shutil import stat import sys @@ -162,3 +163,13 @@ def pattern_match(pattern, string, wildcard="[WILDCARD]"): string = string[(found + len(parts[i])):] return len(string) == 0 + + +def parse_exit_code(s): + codes = [int(d or 1) for d in re.findall(r'error(\d*)', s)] + if len(codes) > 1: + assert False, "doesn't support multiple error codes." + elif len(codes) == 1: + return codes[0] + else: + return 0 -- cgit v1.2.3