#!/bin/bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run stylelint inside the web container
## Usage: stylelint [flags] [args]
## Example: "ddev stylelint"
## ExecRaw: true

# Changed to follow https://github.com/ddev/ddev-drupal-contrib/pull/83
if $DDEV_DOCROOT/core/node_modules/.bin/stylelint --version >/dev/null ; then
   # Change directory to the project root folder
   cd "$DDEV_DOCROOT/modules/custom/${DDEV_SITENAME//-/_}" || exit
   "$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core/node_modules/.bin/stylelint" --color --config "$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core/.stylelintrc.json" "./**/*.css" "$@"
else
  echo "stylelint is not available. You may need to 'ddev yarn --cwd $DDEV_DOCROOT/core install'"
  exit 1
fi
