From ebe4d39f175f73e4f130972cb3d74ef0af5d5761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 18 Jul 2018 10:00:50 +0200 Subject: resource/postcss: Try node_modules/postcss-cli/bin/postcss first Fixes #4952 --- resource/postcss/postcss.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'resource') diff --git a/resource/postcss/postcss.go b/resource/postcss/postcss.go index 7dd27b2f9..3b2b4175a 100644 --- 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 -- cgit v1.2.3