From 4036d0f03547dc6e4b9a12974ddf42125f06ebaa Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Fri, 5 Aug 2022 15:28:22 -0500 Subject: [PATCH] Add a workflow to verify Prettier formatting --- .github/workflows/check-formatting.yml | 26 ++++++++++++++++++++++++++ package.json | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check-formatting.yml diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml new file mode 100644 index 0000000..63ba8fa --- /dev/null +++ b/.github/workflows/check-formatting.yml @@ -0,0 +1,26 @@ +name: Checking formatting + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node.JS + uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Verify formatting + run: npm run format:check diff --git a/package.json b/package.json index 1f9e0b6..a4f4da0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "description": "A GitHub Action to enable Pages and extract various metadata about a site. It can also be used to configure various static site generators we support as starter workflows.", "main": "./dist/index.js", "scripts": { - "prepare": "ncc build src/index.js -o dist --source-map --license licenses.txt", + "format": "prettier --write 'src/**/*.js'", + "format:check": "prettier --check 'src/**/*.js'", + "prepare": "npm run format && ncc build src/index.js -o dist --source-map --license licenses.txt", "test": "jest" }, "repository": {