#!/usr/bin/env 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

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 exec \"cd $DDEV_DOCROOT/core && yarn install\"'"
  exit 1
fi
