changeset 1112:a3dec0fbd9ce

bake: Fix bug on Windows where shim scripts of NodeJS tools couldn't run.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 20 Feb 2018 22:15:57 -0800
parents 98c7dd6ea4ac
children 29c51b981c17
files piecrust/processing/browserify.py piecrust/processing/compressors.py piecrust/processing/less.py piecrust/processing/sass.py
diffstat 4 files changed, 28 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/processing/browserify.py	Sun Feb 18 20:37:54 2018 -0800
+++ b/piecrust/processing/browserify.py	Tue Feb 20 22:15:57 2018 -0800
@@ -29,7 +29,10 @@
         if self._conf is True:
             self._conf = {}
 
-        self._conf.setdefault('bin', 'browserify')
+        bin_name = 'browserify'
+        if platform.system() == 'Windows':
+            bin_name += '.cmd'
+        self._conf.setdefault('bin', bin_name)
 
     def onPipelineStart(self, ctx):
         self._tmp_dir = ctx.tmp_dir
--- a/piecrust/processing/compressors.py	Sun Feb 18 20:37:54 2018 -0800
+++ b/piecrust/processing/compressors.py	Tue Feb 20 22:15:57 2018 -0800
@@ -36,11 +36,8 @@
         args.append(path)
         logger.debug("Cleaning CSS file: %s" % args)
 
-        # On Windows, we need to run the process in a shell environment
-        # otherwise it looks like `PATH` isn't taken into account.
-        shell = (platform.system() == 'Windows')
         try:
-            retcode = subprocess.call(args, shell=shell)
+            retcode = subprocess.call(args)
         except FileNotFoundError as ex:
             logger.error("Tried running CleanCSS processor with command: %s" %
                          args)
@@ -55,8 +52,12 @@
         if self._conf is not None:
             return
 
+        bin_name = 'cleancss'
+        if platform.system() == 'Windows':
+            bin_name += '.cmd'
+
         self._conf = self.app.config.get('cleancss') or {}
-        self._conf.setdefault('bin', 'cleancss')
+        self._conf.setdefault('bin', bin_name)
         self._conf.setdefault('options', ['--skip-rebase'])
         self._conf.setdefault('out_ext', '.css')
         if len(self._conf['out_ext']) > 0 and self._conf['out_ext'][0] != '.':
@@ -83,11 +84,8 @@
         args += self._conf['options']
         logger.debug("Uglifying JS file: %s" % args)
 
-        # On Windows, we need to run the process in a shell environment
-        # otherwise it looks like `PATH` isn't taken into account.
-        shell = (platform.system() == 'Windows')
         try:
-            retcode = subprocess.call(args, shell=shell)
+            retcode = subprocess.call(args)
         except FileNotFoundError as ex:
             logger.error("Tried running UglifyJS processor with command: %s" %
                          args)
@@ -102,10 +100,13 @@
         if self._conf is not None:
             return
 
+        bin_name = 'uglifyjs'
+        if platform.system() == 'Windows':
+            bin_name += '.cmd'
+
         self._conf = self.app.config.get('uglifyjs') or {}
-        self._conf.setdefault('bin', 'uglifyjs')
+        self._conf.setdefault('bin', bin_name)
         self._conf.setdefault('options', ['--compress'])
         if not isinstance(self._conf['options'], list):
             raise Exception("The `uglify/options` configuration setting "
                             "must be an array of arguments.")
-
--- a/piecrust/processing/less.py	Sun Feb 18 20:37:54 2018 -0800
+++ b/piecrust/processing/less.py	Tue Feb 20 22:15:57 2018 -0800
@@ -77,13 +77,8 @@
         args.append(out_path)
         logger.debug("Processing LESS file: %s" % args)
 
-        # On Windows, we need to run the process in a shell environment
-        # otherwise it looks like `PATH` isn't taken into account.
-        shell = (platform.system() == 'Windows')
         try:
-            proc = subprocess.Popen(
-                args, shell=shell,
-                stderr=subprocess.PIPE)
+            proc = subprocess.Popen(args, stderr=subprocess.PIPE)
             stdout_data, stderr_data = proc.communicate()
         except FileNotFoundError as ex:
             logger.error("Tried running LESS processor with command: %s" %
@@ -105,8 +100,12 @@
         if self._conf is not None:
             return
 
+        bin_name = 'lessc'
+        if platform.system() == 'Windows':
+            bin_name += '.cmd'
+
         self._conf = self.app.config.get('less') or {}
-        self._conf.setdefault('bin', 'lessc')
+        self._conf.setdefault('bin', bin_name)
         self._conf.setdefault('options', ['--compress'])
         if not isinstance(self._conf['options'], list):
             raise Exception("The `less/options` configuration setting "
--- a/piecrust/processing/sass.py	Sun Feb 18 20:37:54 2018 -0800
+++ b/piecrust/processing/sass.py	Tue Feb 20 22:15:57 2018 -0800
@@ -83,11 +83,8 @@
         args += [in_path, out_path]
         logger.debug("Processing Sass file: %s" % args)
 
-        # On Windows, we need to run the process in a shell environment
-        # otherwise it looks like `PATH` isn't taken into account.
-        shell = (platform.system() == 'Windows')
         try:
-            retcode = subprocess.call(args, shell=shell)
+            retcode = subprocess.call(args)
         except FileNotFoundError as ex:
             logger.error("Tried running Sass processor with command: %s" %
                          args)
@@ -114,8 +111,12 @@
         if self._conf is not None:
             return
 
+        bin_name = 'scss'
+        if platform.system() == 'Windows':
+            bin_name += '.cmd'
+
         self._conf = self.app.config.get('sass') or {}
-        self._conf.setdefault('bin', 'scss')
+        self._conf.setdefault('bin', bin_name)
         self._conf.setdefault('style', 'nested')
         self._conf.setdefault('load_paths', [])
         if not isinstance(self._conf['load_paths'], list):