comparison piecrust/processing/sass.py @ 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 e00ff3dcb5ec
children
comparison
equal deleted inserted replaced
1111:98c7dd6ea4ac 1112:a3dec0fbd9ce
81 81
82 args += self._conf['options'] 82 args += self._conf['options']
83 args += [in_path, out_path] 83 args += [in_path, out_path]
84 logger.debug("Processing Sass file: %s" % args) 84 logger.debug("Processing Sass file: %s" % args)
85 85
86 # On Windows, we need to run the process in a shell environment
87 # otherwise it looks like `PATH` isn't taken into account.
88 shell = (platform.system() == 'Windows')
89 try: 86 try:
90 retcode = subprocess.call(args, shell=shell) 87 retcode = subprocess.call(args)
91 except FileNotFoundError as ex: 88 except FileNotFoundError as ex:
92 logger.error("Tried running Sass processor with command: %s" % 89 logger.error("Tried running Sass processor with command: %s" %
93 args) 90 args)
94 raise Exception("Error running Sass processor. " 91 raise Exception("Error running Sass processor. "
95 "Did you install it?") from ex 92 "Did you install it?") from ex
112 109
113 def _ensureInitialized(self): 110 def _ensureInitialized(self):
114 if self._conf is not None: 111 if self._conf is not None:
115 return 112 return
116 113
114 bin_name = 'scss'
115 if platform.system() == 'Windows':
116 bin_name += '.cmd'
117
117 self._conf = self.app.config.get('sass') or {} 118 self._conf = self.app.config.get('sass') or {}
118 self._conf.setdefault('bin', 'scss') 119 self._conf.setdefault('bin', bin_name)
119 self._conf.setdefault('style', 'nested') 120 self._conf.setdefault('style', 'nested')
120 self._conf.setdefault('load_paths', []) 121 self._conf.setdefault('load_paths', [])
121 if not isinstance(self._conf['load_paths'], list): 122 if not isinstance(self._conf['load_paths'], list):
122 raise Exception("The `sass/load_paths` configuration setting " 123 raise Exception("The `sass/load_paths` configuration setting "
123 "must be an array of paths.") 124 "must be an array of paths.")