diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-07-18 10:00:50 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-07-18 10:00:50 +0200 |
commit | ebe4d39f175f73e4f130972cb3d74ef0af5d5761 (patch) | |
tree | 91820750cf589834bda44197eec41fd5c60ca511 /resource | |
parent | 1b0aeeaaf0f8839347f12b544a2172e2e3c8854b (diff) |
resource/postcss: Try node_modules/postcss-cli/bin/postcss first
Fixes #4952
Diffstat (limited to 'resource')
-rw-r--r-- | resource/postcss/postcss.go | 16 |
1 files changed, 13 insertions, 3 deletions
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 |