Start Building for Free
CircleCI.comBlogCommunitySupport

cfra/prettier

A shareable package of CircleCI configuration to integrate with prettier, written by cfra

Community
  • Orb Quick Start Guide
  • Usage Examples
    • check
    • write-commit-push
  • Jobs
  • Commands
  • Executors
  • Orb Source
  1. Orbs
  2. cfra/prettier@0.1.1

cfra/prettier@0.1.1

Sections
Check and/or fix formatting of source code using prettier. Source can be found at https://github.com/PicturePipe/prettier-orb/
Created: March 4, 2019Version Published: April 3, 2019Releases: 2
Org Usage:
< 25

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: prettier: cfra/prettier@0.1.1

Use prettier elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Read more in the docs here.

Usage Examples

check

Check formatting of source code using prettier. If your project does not contain a .prettierrc.json, a default style will be used.

1 2 3 4 5 6 7 orbs: prettier: picturepipe/prettier@volatile version: 2.1 workflows: build: jobs: - prettier/check

write-commit-push

Run prettier write and push new formatting of source code back to repository. If your project does not contain a .prettierrc.json, a default style will be used.

1 2 3 4 5 6 7 orbs: prettier: picturepipe/prettier@volatile version: 2.1 workflows: build: jobs: - prettier/write-commit-push

Jobs

check

Check formatting of source code using prettier. If your project does not contain a .prettierrc.json, a default style will be used.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
arguments
Arguments to pass to prettier.
Arguments to pass to prettier.
No
'''./**'''
type: string
string

write-commit-push

Run prettier write and push new formatting of source code back to repository. If your project does not contain a .prettierrc.json, a default style will be used.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
arguments
Arguments to pass to prettier.
Arguments to pass to prettier.
No
'''./**'''
type: string
string
remote-url
Specify if the push should be made to a remote other than origin.
Specify if the push should be made to a remote other than origin.
No
''
type: string
string

Commands

commit-push

Perform a git commit and push it back upstream

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
remote-url
Specify if the push should be made to a remote other than origin.
Specify if the push should be made to a remote other than origin.
No
''
type: string
string

setup

Put standard .prettierrc.json if none is present

Show command Source

Executors

default

The docker image to use for running prettier tasks.

Show executor Source

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing commands: commit-push: description: | Perform a git commit and push it back upstream parameters: remote-url: default: "" description: | Specify if the push should be made to a remote other than origin. type: string steps: - run: command: | git config --global user.email "$CIRCLE_USERNAME@users.noreply.github.com" git config --global user.name "$CIRCLE_USERNAME" if [ -z "<< parameters.remote-url>>" ]; then REMOTE_URL="$(git remote get-url origin)" else REMOTE_URL="<< parameters.remote-url >>" fi if [ -n "$(git status --porcelain --untracked-files=no)" ]; then git commit --all --message "Format code with Prettier" git push "$REMOTE_URL" "HEAD:${CIRCLE_BRANCH}" echo "We fixed formatting and pushed a commit." >&2 echo "Testing will continue at that commit, so indicating failure here. ♻" >&2 exit 1 else echo "No changes to commit, everything is pretty. ✨" >&2 fi name: Configure git, commit changes and push them upstream setup: description: | Put standard .prettierrc.json if none is present steps: - run: command: "if [ ! -e \".prettierrc.json\" ]; then\n\tcat > .prettierrc.json \\<<-'EOF'\n\t\t{\n\t\t \"printWidth\": 99,\n\t\t \"proseWrap\": \"always\"\n\t\t}\n\tEOF\nfi\n" name: Put default .prettierrc.json if needed description: | Check and/or fix formatting of source code using prettier. Source can be found at https://github.com/PicturePipe/prettier-orb/ examples: check: description: | Check formatting of source code using prettier. If your project does not contain a .prettierrc.json, a default style will be used. usage: orbs: prettier: picturepipe/prettier@volatile version: 2.1 workflows: build: jobs: - prettier/check write-commit-push: description: | Run prettier write and push new formatting of source code back to repository. If your project does not contain a .prettierrc.json, a default style will be used. usage: orbs: prettier: picturepipe/prettier@volatile version: 2.1 workflows: build: jobs: - prettier/write-commit-push executors: default: description: | The docker image to use for running prettier tasks. docker: - image: quay.io/picturepipe/prettier:latest jobs: check: description: | Check formatting of source code using prettier. If your project does not contain a .prettierrc.json, a default style will be used. executor: default parameters: arguments: default: '''./**''' description: | Arguments to pass to prettier. type: string steps: - checkout - setup - run: command: prettier --check <<parameters.arguments>> name: Prettier Check write-commit-push: description: | Run prettier write and push new formatting of source code back to repository. If your project does not contain a .prettierrc.json, a default style will be used. executor: default parameters: arguments: default: '''./**''' description: | Arguments to pass to prettier. type: string remote-url: default: "" description: | Specify if the push should be made to a remote other than origin. type: string steps: - checkout - setup - run: command: prettier --write <<parameters.arguments>> name: Prettier Write - commit-push: remote-url: << parameters.remote-url >> version: 2.1
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.