diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..27da8d0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build the package + +on: + workflow_dispatch: + pull_request: + types: [opened, reopened] + push: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install dependencies + run: npm ci + + - name: Build the package + run: npm run build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ab584cb --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Build the package + +on: + workflow_dispatch: + pull_request: + types: [opened, reopened] + push: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Build the package + run: bash ./scripts/lint.sh diff --git a/.npmignore b/.npmignore index 1dfd532..1c57736 100644 --- a/.npmignore +++ b/.npmignore @@ -7,6 +7,9 @@ # ci/cd .github/ +# bash scripts +scripts/ + # dependencies node_modules/ diff --git a/package.json b/package.json index 683059d..c2432c7 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "test": "ts-node ./utils/test.ts", "build": "npx tsc", "postinstall": "node postinstall.js", - "lint": "eslint ./", - "lint:fix": "eslint ./ --fix" + "lint": "bash ./scripts/lint.sh", + "lint:fix": "bash ./scripts/lint.sh --fix" }, "author": "shadowplay1 ", "license": "MIT", diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100644 index 0000000..652edcd --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +output="" + + +lint() { + if [[ $1 == '--fix' ]]; then + echo 'Fixing all the fixable linting issues...' + echo + + eslint ./src --fix & output=$(eslint ./src --fix) + else + echo 'Checking the code for linting issues...' + echo + + eslint ./src & output=$(eslint ./src) + fi +} + + +lint $1 + +if [ -n "$output" ]; then + echo 'Linting check failed.' + exit 1 +else + echo 'Linting check passed!' + exit 0 +fi