From c2c72b82ea0fa7ff6aa05a1b0a83d26dbfaa1d9a Mon Sep 17 00:00:00 2001 From: Jared Lunde Date: Sat, 25 Sep 2021 08:14:56 -0600 Subject: [PATCH] fix: improve cache check (#3) * fix: remove superfluous has() check * chore: remove type checking from lint-staged --- .github/workflows/release.yml | 38 ++++++----------------------------- package.json | 2 +- src/index.ts | 18 ++++++++--------- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f419c9..d6a29c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,8 +11,8 @@ on: - next jobs: - install-and-verify: - name: 🏗️ Install and verify + release: + name: 🚀 Release if: "!contains(github.event.head_commit.message, '[skip ci]') && !startsWith(github.event.head_commit.message, 'chore:') && !startsWith(github.event.head_commit.message, 'style:') && !contains(github.event.pull_request.title, '[skip ci]') && !startsWith(github.event.pull_request.title, 'chore:') && !startsWith(github.event.pull_request.title, 'style:') && !startsWith(github.event.head_commit.message, 'chore(') && !startsWith(github.event.head_commit.message, 'style(') && !startsWith(github.event.pull_request.title, 'chore(') && !startsWith(github.event.pull_request.title, 'style(')" runs-on: ubuntu-latest strategy: @@ -51,40 +51,14 @@ jobs: files: coverage/clover.xml verbose: false fail_ci_if_error: false - - publish: - name: 🚀 Publish - # Don't run deployments for test-only commits/PRs - if: "github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next') && !startsWith(github.event.head_commit.message, 'test:') && !startsWith(github.event.pull_request.title, 'test:') && !startsWith(github.event.head_commit.message, 'test(') && !startsWith(github.event.pull_request.title, 'test(')" - # if: "!startsWith(github.event.head_commit.message, 'test:') && !startsWith(github.event.pull_request.title, 'test:') && !startsWith(github.event.head_commit.message, 'test(') && !startsWith(github.event.pull_request.title, 'test(')" - runs-on: ubuntu-latest - needs: install-and-verify - strategy: - matrix: - node-version: [16.x] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup pnpm - uses: pnpm/action-setup@v2.0.1 - with: - version: 6.14.3 - - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Load node_modules - id: cache-node-modules - uses: actions/cache@v2 - with: - path: node_modules - key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Build + if: "github.event_name == 'push'" run: pnpm build - name: Stage changes + if: "github.event_name == 'push'" run: git add . - - name: Release + - name: 🚀 Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: pnpx -y semantic-release --ci --dry-run + run: pnpx -y semantic-release diff --git a/package.json b/package.json index 824f212..8947aae 100755 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "husky": { "hooks": { - "pre-commit": "lundle check-types && lint-staged", + "pre-commit": "lint-staged", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } }, diff --git a/src/index.ts b/src/index.ts index 8eab9d8..0d14864 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,14 +38,12 @@ function compound( const mapKeys: string[] = [] mapKeys.push(...Object.keys(styleMap)) - function atomicCss( - compoundMap: {[Name in keyof StyleMap]?: Parameters[0]} - ): string[] { + function atomicCss(compoundMap: { + [Name in keyof StyleMap]?: Parameters[0] + }): string[] { const key = JSON.stringify(compoundMap) - - if (cache.has(key)) { - return cache.get(key) || [] - } + const cached = cache.get(key) + if (cached) return cached const output: string[] = // @ts-expect-error @@ -68,9 +66,9 @@ function compound( return output } - function css( - compoundMap: {[Name in keyof StyleMap]?: Parameters[0]} - ): string { + function css(compoundMap: { + [Name in keyof StyleMap]?: Parameters[0] + }): string { const css = atomicCss(compoundMap) let output = '' let i = 0