commit ebe4d39f175f73e4f130972cb3d74ef0af5d5761
parent 1b0aeeaaf0f8839347f12b544a2172e2e3c8854b
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Wed, 18 Jul 2018 10:00:50 +0200
resource/postcss: Try node_modules/postcss-cli/bin/postcss first
Fixes #4952
Diffstat:
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/resource/postcss/postcss.go b/resource/postcss/postcss.go
@@ -98,11 +98,21 @@ func (t *postcssTransformation) Key() resource.ResourceTransformationKey {
// npm install -g autoprefixer
func (t *postcssTransformation) Transform(ctx *resource.ResourceTransformationCtx) error {
- const binary = "postcss"
+ const localPostCSSPath = "node_modules/postcss-cli/bin/"
+ const binaryName = "postcss"
+
+ // Try first in the project's node_modules.
+ csiBinPath := filepath.Join(t.rs.WorkingDir, localPostCSSPath, binaryName)
+
+ binary := csiBinPath
if _, err := exec.LookPath(binary); err != nil {
- // This may be on a CI server etc. Will fall back to pre-built assets.
- return errors.FeatureNotAvailableErr
+ // Try PATH
+ binary = binaryName
+ if _, err := exec.LookPath(binary); err != nil {
+ // This may be on a CI server etc. Will fall back to pre-built assets.
+ return errors.FeatureNotAvailableErr
+ }
}
var configFile string