shithub: hugo

Download patch

ref: ebe4d39f175f73e4f130972cb3d74ef0af5d5761
parent: 1b0aeeaaf0f8839347f12b544a2172e2e3c8854b
author: Bjørn Erik Pedersen <[email protected]>
date: Wed Jul 18 06:00:50 EDT 2018

resource/postcss: Try node_modules/postcss-cli/bin/postcss first

Fixes #4952

--- a/resource/postcss/postcss.go
+++ b/resource/postcss/postcss.go
@@ -98,11 +98,21 @@
 // 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