Skip to content

Commit d4b5e37

Browse files
committed
Combine CI and CD workflows, minor doc updates
1 parent 0204642 commit d4b5e37

File tree

7 files changed

+66
-62
lines changed

7 files changed

+66
-62
lines changed

.github/workflows/label-sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches: [main]
7-
paths: [.github/labels.yml]
7+
paths: [".github/labels.yml"]
88

99
jobs:
1010
sync:

.github/workflows/continuous-integration.yml renamed to .github/workflows/pipeline.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
name: Continuous Integration
1+
name: Pipeline
22

33
on:
44
push:
55
branches: [main]
6+
paths: ["package.json", "src/**", "tests/**"]
67
pull_request:
78
branches: [main]
89
types: [opened, synchronize, reopened]
10+
paths: ["package.json", "src/**", "tests/**"]
911
workflow_dispatch:
10-
workflow_call:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
1116

1217
jobs:
1318
check:
@@ -24,7 +29,7 @@ jobs:
2429
- name: Run the type checker
2530
run: pnpm check
2631

27-
quality:
32+
lint:
2833
name: Linting
2934
runs-on: ubuntu-latest
3035

@@ -54,7 +59,7 @@ jobs:
5459

5560
test:
5661
name: Testing
57-
needs: build
62+
needs: [build]
5863
runs-on: ubuntu-latest
5964

6065
steps:
@@ -64,5 +69,30 @@ jobs:
6469
- name: Setup Node.js
6570
uses: ./.github/actions/node
6671

72+
- name: Install playwright browsers
73+
run: pnpm playwright install --with-deps
74+
6775
- name: Run tests
6876
run: pnpm test
77+
78+
release:
79+
name: Releasing Snapshot
80+
needs: [test]
81+
runs-on: ubuntu-latest
82+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
83+
84+
steps:
85+
- name: Checkout repository
86+
uses: actions/checkout@v4
87+
88+
- name: Setup Node.js
89+
uses: ./.github/actions/node
90+
91+
- name: Publish snapshot version
92+
run: |
93+
pnpm changeset version --snapshot beta
94+
pnpm biome format package.json --write
95+
pnpm build
96+
pnpm changeset publish --tag beta --no-git-tag
97+
env:
98+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR Triage
1+
name: Pull Request Triage
22

33
on:
44
pull_request:

.github/workflows/release-snapshot.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,40 +71,44 @@ The `createMs` function allows you to create a new instance of `ms` with a custo
7171
function createMs(options?: CreateMsOptions): typeof ms;
7272
```
7373

74-
| Option | Type | Description | Default |
75-
| --------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------- |
76-
| `language` | `Locale` \| `LanguageDefinition` | The language to use for parsing and formatting, if your preferred isn't supported, you can directly pass a language definition. | `en` |
77-
| `formatOptions` | `FormatOptions` | The options to use for formatting. | see below |
78-
| `parseOptions` | `ParseOptions` | The options to use for parsing. | see below |
74+
| Option | Type | Description | Default |
75+
| --------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------- |
76+
| `language` | `Locale` \| `LanguageDefinition` | The language to use for parsing and formatting, if your preferred isn't supported, you can directly pass a language definition. | `en` |
77+
| `formatOptions` | `FormatOptions` \| `FormatOptionsPreset` | The options to use for formatting. | see below |
7978

8079
### Formatting Milliseconds to Duration
8180

82-
The `ms` function allows you to format a number of milliseconds to a duration string. Passing a number of milliseconds will return a duration string, if the number is invalid, it will return `null`.
81+
The `ms` function allows you to format a number of milliseconds to a duration string. Passing a number of milliseconds will return a duration string, if the number is invalid, it will return `null`. The milliseconds overloads also allows you to pass a `FormatOptions` object or a `FormatOptionsPreset` to customise the formatting.
8382

8483
```ts
85-
function ms(milliseconds: number, options?: FormatOptions): string | null;
84+
function ms(milliseconds: number): string | null;
85+
function ms(milliseconds: number, options: FormatOptions): string | null;
86+
function ms(milliseconds: number, preset: FormatOptionsPreset): string | null;
8687
```
8788

88-
| Option | Type | Description | Default |
89-
| ------------------ | ------------------------------------ | -------------------------------------------------------- | ------- |
90-
| `includeMs` | `boolean` | Include the milliseconds in the output. | `false` |
91-
| `includeSubMs` | `boolean` | Include the sub-milliseconds in the output. | `false` |
92-
| `formatStyle` | `'short'` \| `'long'` | Specify the format style of the output. | `long` |
93-
| `insertAnd` | `boolean` | Insert the `and` value between the units. | `false` |
94-
| `insertCommas` | `boolean` | Insert commas between the units. | `false` |
95-
| `firstUnitOnly` | `boolean` | Only show the highest unit in the output | `false` |
96-
| `unitCount` | `number` | The number of units to show in the output, `-1` for all. | `-1` |
97-
| `roundingStrategy` | `'floor'` \| `'ceil'` \| `'nearest'` | The rounding strategy to use when cutting off units. | `floor` |
89+
| Option | Type | Description | Default |
90+
| ------------------ | --------------------- | ------------------------------------------------------------------ | --------------------------------------------- |
91+
| `extends` | `FormatOptionsPreset` | Extends the preset with the given options. | none |
92+
| `hideUnitNames` | `boolean` | Hide unit names from the output. | `false` |
93+
| `useAbbreviations` | `boolean` | Use abbreviations for unit names. | `false` |
94+
| `includeZero` | `boolean` | Include units with the value 0 in the output. | `false` |
95+
| `includeMs` | `boolean` | Include milliseconds in the output. | `false` |
96+
| `includeSubMs` | `boolean` | Include sub-millisecond units in the output. | `false` |
97+
| `includedUnits` | `ParseUnit[]` | Which units should be included in the output. | `['year', 'day', 'hour', 'minute', 'second']` |
98+
| `unitLimit` | `number` | The maximum number of units to include in the output. | `-1` |
99+
| `unitSeparator` | `string` | The separator to use between units. | ` ` |
100+
| `minimumDigits` | `number` | The minimum number of digits for a unit, aka will pad with zeroes. | `0` |
101+
102+
| Preset | Example |
103+
| --------------- | -------------------------------------------------------------- |
104+
| `short` | `1m 30s` |
105+
| `fullPrecision` | `10 seconds 100 milliseconds 100 microseconds 100 nanoseconds` |
106+
| `colonNotation` | `00:01:30` |
98107

99108
### Parsing Duration to Milliseconds
100109

101110
The `ms` function also allows you to parse a duration string (`1 day`, `3 weeks 4 days`, etc). Passing a duration string will return a number of milliseconds, if no valid duration units are found, it will return `0`.
102111

103112
```ts
104-
function ms(duration: string, options?: ParseOptions): number;
113+
function ms(duration: string): number;
105114
```
106-
107-
| Option | Type | Description | Default |
108-
| ------ | ---- | ----------- | ------- |
109-
110-
N/A

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"test": "vitest --run",
4242
"prepare": "husky",
4343
"change": "changeset",
44-
"release": "changeset version && pnpm format && pnpm build && changeset publish"
44+
"release": "changeset version && pnpm biome package.json --write && pnpm build && changeset publish"
4545
},
4646
"devDependencies": {
4747
"@biomejs/biome": "^1.9.4",

src/format/helpers/resolve-options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ParseUnit } from './parse-milliseconds';
44

55
export interface FormatOptions {
66
/**
7-
* The preset to extend.
7+
* Extends the preset with the given options.
88
*/
99
extends?: FormatOptionsPreset;
1010

@@ -16,7 +16,7 @@ export interface FormatOptions {
1616
hideUnitNames?: boolean;
1717

1818
/**
19-
* Use abbreviations for units.
19+
* Use abbreviations for unit names.
2020
* @default false
2121
*/
2222
useAbbreviations?: boolean;

0 commit comments

Comments
 (0)