From 9f9e3cfe810bbe65fd019ad68c2ef31cd40a5fa1 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Tue, 22 Mar 2016 17:01:42 -0600 Subject: [PATCH 1/2] Enable passing of and arguments in pipeline compiler --- react/utils/pipeline.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/react/utils/pipeline.py b/react/utils/pipeline.py index 7fc8932..4d33fbc 100644 --- a/react/utils/pipeline.py +++ b/react/utils/pipeline.py @@ -16,6 +16,7 @@ from pipeline.compilers import CompilerBase from pipeline.exceptions import CompilerError +from pipeline.conf import settings from react.jsx import JSXTransformer, TransformError class JSXCompiler(CompilerBase): @@ -31,7 +32,23 @@ def match_file(self, path): def compile_file(self, infile, outfile, outdated=False, force=False): if not outdated and not force: return + + try: + harmony = settings.REACT_HARMONY + except KeyError: + harmony = False + + try: + strip_types = settings.REACT_STRIP_TYPES + except KeyError: + strip_types = False + try: - return self.transformer.transform(infile, outfile) + return self.transformer.transform( + infile, + outfile, + harmony=harmony, + strip_types=strip_types, + ) except TransformError as e: raise CompilerError(str(e)) From 7ba37bac6adb9d02bf9557bcc15d7ccfab3d845d Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Tue, 22 Mar 2016 17:08:11 -0600 Subject: [PATCH 2/2] support pipeline < 1.6 --- react/utils/pipeline.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/react/utils/pipeline.py b/react/utils/pipeline.py index 4d33fbc..79ecd9f 100644 --- a/react/utils/pipeline.py +++ b/react/utils/pipeline.py @@ -33,14 +33,16 @@ def compile_file(self, infile, outfile, outdated=False, force=False): if not outdated and not force: return + # pipeline < 1.6 will raise `AttributeError` + # pipeline >= 1.6 will raise `KeyError` try: harmony = settings.REACT_HARMONY - except KeyError: + except (KeyError, AttributeError): harmony = False try: strip_types = settings.REACT_STRIP_TYPES - except KeyError: + except (KeyError, AttributeError): strip_types = False try: