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

Fixes #4952
This commit is contained in:
Bjørn Erik Pedersen 2018-07-18 10:00:50 +02:00
parent 1b0aeeaaf0
commit ebe4d39f17
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -98,11 +98,21 @@ func (t *postcssTransformation) Key() resource.ResourceTransformationKey {
// npm install -g autoprefixer // npm install -g autoprefixer
func (t *postcssTransformation) Transform(ctx *resource.ResourceTransformationCtx) error { 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 { if _, err := exec.LookPath(binary); err != nil {
// This may be on a CI server etc. Will fall back to pre-built assets. // Try PATH
return errors.FeatureNotAvailableErr 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 var configFile string