From: Bjørn Erik Pedersen Date: Wed, 18 Jul 2018 08:00:50 +0000 (+0200) Subject: resource/postcss: Try node_modules/postcss-cli/bin/postcss first X-Git-Tag: v0.45~28 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ebe4d39f175f73e4f130972cb3d74ef0af5d5761;p=brevno-suite%2Fhugo resource/postcss: Try node_modules/postcss-cli/bin/postcss first Fixes #4952 --- diff --git a/resource/postcss/postcss.go b/resource/postcss/postcss.go index 7dd27b2f..3b2b4175 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