stylelint/entrypoint.sh

36 lines
699 B
Bash
Raw Permalink Normal View History

2019-08-21 16:01:23 -04:00
#!/bin/sh
set -e
2019-11-11 07:12:02 -05:00
configPath="./"
indentSpaces=2
pattern="*.css"
if [ ! -z "${CONFIG_PATH}" ]; then
configPath=$CONFIG_PATH
fi
if [ ! -z "${INDENT_SPACES}" ]; then
indent_spaces=$INDENT_SPACES
fi
if [ ! -z "${PATTERN}" ]; then
pattern=$PATTERN
fi
2019-08-21 16:01:23 -04:00
stylelint_path="node_modules/.bin/stylelint"
2019-08-21 16:01:23 -04:00
if [ ! -e stylelint_path ]; then
2019-10-25 13:35:47 -04:00
yarn add stylelint stylelint-config-standard --silent
2019-08-21 16:01:23 -04:00
fi
2019-11-11 07:13:54 -05:00
if [ ! -e "${configPath}.stylelintrc" ] && [ ! -e "${configPath}.stylelint.json" ]; then
2019-10-25 13:35:47 -04:00
echo "{
2019-08-21 16:01:23 -04:00
\"extends\": \"stylelint-config-standard\",
\"rules\": {
\"indentation\": "$indentSpaces"
2019-08-21 16:01:23 -04:00
}
}" > .stylelintrc
fi
echo ::add-path::${stylelint_path}
2019-08-21 16:01:23 -04:00
2019-11-11 07:12:02 -05:00
echo $pattern
2019-08-21 16:01:23 -04:00
sh -c "$stylelint_path $pattern"