Skip to content

Commit

Permalink
Merge pull request #544 from swrlab/dev/update-1.1.3
Browse files Browse the repository at this point in the history
Update v1.1.3
  • Loading branch information
rafaelmaeuer committed Jun 12, 2023
2 parents b664b68 + 63084f9 commit 4e3baec
Show file tree
Hide file tree
Showing 10 changed files with 291 additions and 203 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Linter

on:
pull_request:
push:
branches-ignore:
- dependabot/**
- "dependabot/**"
workflow_call:
inputs:
install-all:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test on Pull

on:
pull_request_target:
types: [labeled]

env:
NODE_VERSION: 18

jobs:
security:
name: Check permissions for pull request runs
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'safe to test')
steps:
- run: |
echo "Security checks passed!"
test:
needs: security
name: Run Mocha Tests
runs-on: ubuntu-latest
steps:
- name: 👀 Checkout Code
uses: actions/checkout@v3

- name: 🏗 Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: "**/yarn.lock"

- name: 📦 Install Dependencies
run: yarn

- name: 🧪 Run Tests
run: yarn lint && yarn test
7 changes: 5 additions & 2 deletions .github/workflows/test.yml → .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test on Push

on:
workflow_dispatch:
Expand All @@ -9,6 +9,9 @@ on:
- dev/*
- main

env:
NODE_VERSION: 18

jobs:
test:
name: Run Mocha Tests
Expand All @@ -20,7 +23,7 @@ jobs:
- name: 🏗 Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: "**/yarn.lock"

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ by [**SWR Audio Lab**](https://lab.swr.de/)

## Changelog

- 2023-04-19 - v1.1.3
- fix: don't run linter on dependabot-pr
- fix: use `toReadable` in `pluralize` helper
- security: add safe-to-test flag for pr's

- 2023-02-15 - v1.1.2
- feat: add `revYearMonthDay` to date package
- feat: add `date` package with iso time functions
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Then run the desired script.
## Packages

- [ARD](./packages/ard) - Common internal ARD tools like ID creation
- [Date](./packages/date) - Common date functions and time helpers
- [Helpers](./packages/helpers) - Common functions and helpers
- [Numbers](./packages/numbers) - Common number and math helpers
- [Storage Wrapper](./packages/storage-wrapper) - A utility to wrap file access to local, Google Cloud Storage and AWS S3 file storage
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swrlab/utils",
"version": "1.1.2",
"version": "1.1.3",
"description": "Wrapping common SWR Audio Lab utils",
"main": "./index.js",
"engines": {
Expand All @@ -23,23 +23,23 @@
"license": "MIT",
"private": false,
"dependencies": {
"@google-cloud/storage": "^6.9.3",
"@google-cloud/storage": "^6.11.0",
"abort-controller": "^3.0.0",
"aws-sdk": "^2.1318.0",
"aws-sdk": "^2.1395.0",
"chai": "^4.3.7",
"luxon": "^3.2.1",
"luxon": "^3.3.0",
"node-crc": "swrlab/node-crc#v2.1.0",
"undici": "^5.20.0",
"undici": "^5.22.1",
"uuid": "9.0.0"
},
"devDependencies": {
"@swrlab/eslint-plugin-swr": "^0.2.0",
"@swrlab/swr-prettier-config": "^0.2.0",
"dotenv": "^16.0.3",
"eslint": "^8.34.0",
"dotenv": "^16.1.4",
"eslint": "^8.42.0",
"eslint-plugin-json": "^3.1.0",
"mocha": "^10.2.0",
"prettier": "^2.8.4"
"prettier": "^2.8.8"
},
"prettier": "@swrlab/swr-prettier-config"
}
8 changes: 4 additions & 4 deletions packages/strings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,14 @@ Then use the toolkit:
pluralize(1, 'Apple')
// 1 Apple

pluralize(2, 'Apple')
// 2 Apples
pluralize(1000, 'Apple')
// 1.000 Apples

pluralize(1, 'Child', 'Children')
// 1 Child

pluralize(2, 'Child', 'Children')
// 2 Children
pluralize(1000, 'Child', 'Children')
// 1.000 Children
```

## `removeDoubleSpaces` - take a string and remove its duplicate spaces
Expand Down
8 changes: 4 additions & 4 deletions tests/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ describe('Test Strings Package', () => {
expect(strings.pluralize(1, 'Apple')).to.equal('1 Apple')
})

it("pluralize(2, 'Apple') = '2 Apples'", () => {
expect(strings.pluralize(2, 'Apple')).to.equal('2 Apples')
it("pluralize(1000, 'Apple') = '1.000 Apples'", () => {
expect(strings.pluralize(1000, 'Apple')).to.equal('1.000 Apples')
})

it("pluralize(1, 'Child', 'Children') = '1 Child'", () => {
expect(strings.pluralize(1, 'Child', 'Children')).to.equal('1 Child')
})

it("pluralize(2, 'Child', 'Children') = '2 Children'", () => {
expect(strings.pluralize(2, 'Child', 'Children')).to.equal('2 Children')
it("pluralize(1000, 'Child', 'Children') = '1.000 Children'", () => {
expect(strings.pluralize(1000, 'Child', 'Children')).to.equal('1.000 Children')
})
})

Expand Down
4 changes: 3 additions & 1 deletion utils/strings/pluralize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const toReadable = require('../numbers/toReadable')

// pluralize value to values or use custom plural
module.exports = (count, singular, plural) => {
const multi = plural ?? `${singular}s`
return `${count} ${count !== 1 ? multi : singular}`
return `${toReadable(count)} ${count !== 1 ? multi : singular}`
}
Loading

0 comments on commit 4e3baec

Please sign in to comment.