Skip to content

Commit

Permalink
fix: improve cache check (#3)
Browse files Browse the repository at this point in the history
* fix: remove superfluous has() check

* chore: remove type checking from lint-staged
  • Loading branch information
jaredLunde authored Sep 25, 2021
1 parent f4696f2 commit c2c72b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 43 deletions.
38 changes: 6 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"husky": {
"hooks": {
"pre-commit": "lundle check-types && lint-staged",
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
Expand Down
18 changes: 8 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ function compound<Tokens extends DashTokens, ThemeNames extends string>(
const mapKeys: string[] = []
mapKeys.push(...Object.keys(styleMap))

function atomicCss(
compoundMap: {[Name in keyof StyleMap]?: Parameters<StyleMap[Name]>[0]}
): string[] {
function atomicCss(compoundMap: {
[Name in keyof StyleMap]?: Parameters<StyleMap[Name]>[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
Expand All @@ -68,9 +66,9 @@ function compound<Tokens extends DashTokens, ThemeNames extends string>(
return output
}

function css(
compoundMap: {[Name in keyof StyleMap]?: Parameters<StyleMap[Name]>[0]}
): string {
function css(compoundMap: {
[Name in keyof StyleMap]?: Parameters<StyleMap[Name]>[0]
}): string {
const css = atomicCss(compoundMap)
let output = ''
let i = 0
Expand Down

0 comments on commit c2c72b8

Please sign in to comment.