mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
resource/postcss: Try node_modules/postcss-cli/bin/postcss first
Fixes #4952
This commit is contained in:
parent
1b0aeeaaf0
commit
ebe4d39f17
1 changed files with 13 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue