Skip to content

Commit

Permalink
Merge pull request #949 from kamadorueda/main
Browse files Browse the repository at this point in the history
feat(back): #0 use prettier
  • Loading branch information
kamadorueda authored Oct 2, 2022
2 parents d24478d + 324ef20 commit 4d4be13
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: richardsimko/update-tag@5bd0e05b035e02d5da3768dbdcfc4e5e0908623e
with:
tag_name: '22.11'
tag_name: "22.11"
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: johnwbyrd/update-release@1d5ec4791e40507e5eca3b4dbf90f0b27e7e4979
with:
files: README.md
release: '22.11'
release: "22.11"
prerelease: true
tag: '22.11'
tag: "22.11"
token: ${{ github.token }}
linux_all:
runs-on: ubuntu-latest
Expand Down
8 changes: 1 addition & 7 deletions src/args/format-yaml/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ makeScript {
searchPaths = {
bin = [
__nixpkgs__.findutils
__nixpkgs__.git
];
source = [
(makePythonPypiEnvironment {
name = "yamlfix";
sourcesYaml = ./sources.yaml;
})
__nixpkgs__.nodePackages.prettier
];
};
entrypoint = ./entrypoint.sh;
Expand Down
36 changes: 13 additions & 23 deletions src/args/format-yaml/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,24 @@

# shellcheck shell=bash

function diff {
git --no-pager diff -G. --no-index "${1}" "${2}" > /dev/null
}

function main {
source __argTargets__/template local targets
local tmp_paths
local tmp_file
local exit_code="0"
local pattern=(
"${targets[@]}"
-name '*.yaml'
-or
-name '*.yml'
)

info "Formatting YAML files" \
&& tmp_paths=$(mktemp) \
&& for target in "${targets[@]}"; do
find "${target}" -wholename '*.yml' -or -wholename '*.yaml' -type f \
| sort --ignore-case > "${tmp_paths}" \
&& while read -r path; do
tmp_file=$(mktemp) \
&& copy "${path}" "${tmp_file}" \
&& yamlfix "${path}" 2> /dev/null \
&& if ! diff "${tmp_file}" "${path}"; then
info "This file does not comply the format. We just formatted it: ${path} " \
&& exit_code="1"
fi \
|| return 1
done < "${tmp_paths}" \
|| return 1
done \
&& return "${exit_code}"
&& if find "${pattern[@]}" -exec prettier --check --parser yaml {} \+; then
return 0
fi \
&& info "Some files do not comply the YAML format. We will format them but this job will fail." \
&& find "${pattern[@]}" -exec prettier --parser yaml --write {} \+

return 1
}

main "${@}"

0 comments on commit 4d4be13

Please sign in to comment.