Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(back): #0 use prettier #949

Merged
merged 1 commit into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "${@}"