From 9c3ed36bc2f8d4bc7685b4735b2885fb4cdc0fea Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Sun, 27 Mar 2016 02:26:42 -0700 Subject: [PATCH] fix publish function so it propagates return code --- tldp/driver.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tldp/driver.py b/tldp/driver.py index 7cc3424..4198232 100644 --- a/tldp/driver.py +++ b/tldp/driver.py @@ -324,18 +324,19 @@ def build(config, docs, **kwargs): def publish(config, docs, **kwargs): config.build = True result = build(config, docs, **kwargs) - if result == os.EX_OK: - for x, source in enumerate(docs, 1): - logger.info("Publishing (%d of %d) to %s.", - x, len(docs), source.output.dirname) - # -- swapdirs must raise an error if there are problems - # - swapdirs(source.working.dirname, source.output.dirname) - if os.path.isdir(source.working.dirname): - logger.debug("%s removing old directory %s", - source.stem, source.working.dirname) - shutil.rmtree(source.working.dirname) - post_publish_cleanup(docs) + if result != os.EX_OK: + return result + for x, source in enumerate(docs, 1): + logger.info("Publishing (%d of %d) to %s.", + x, len(docs), source.output.dirname) + # -- swapdirs must raise an error if there are problems + # + swapdirs(source.working.dirname, source.output.dirname) + if os.path.isdir(source.working.dirname): + logger.debug("%s removing old directory %s", + source.stem, source.working.dirname) + shutil.rmtree(source.working.dirname) + post_publish_cleanup(docs) return os.EX_OK