Skip to content

Commit b6bb37b

Browse files
committed
chore: fixes to types and jsr publish
1 parent 49d677e commit b6bb37b

File tree

7 files changed

+33
-12
lines changed

7 files changed

+33
-12
lines changed

.changeset/new-cherries-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cdn-cache-control": patch
3+
---
4+
5+
Fixes to types

jsr.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
2-
"name": "@ascorbic/cdn-cache-control",
3-
"version": "1.3.0",
4-
"exports": "./src/index.ts",
5-
"license": "MIT"
6-
}
2+
"name": "@ascorbic/cdn-cache-control",
3+
"version": "1.3.0",
4+
"exports": "./src/index.ts",
5+
"license": "MIT",
6+
"publish": {
7+
"include": [
8+
"README.md",
9+
"src/index.ts"
10+
]
11+
}
12+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"lint:package": "publint",
4444
"lint:prettier": "prettier --check src",
4545
"lint": "pnpm run '/^lint:.*/'",
46-
"test": "pnpm build && node --test",
46+
"test": "pnpm build && node --test test",
4747
"tsdoc": "tsdoc --src=src/index.ts && prettier --write README.md",
4848
"version": "changeset version && jq --arg version \"$(jq -r .version package.json)\" '.version = $version' jsr.json > jsr.json.tmp && mv jsr.json.tmp jsr.json"
4949
},

src/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ const cdnCacheControlHeaderNames = new Map<CDN, string>([
2929
["fastly", "Cache-Control"],
3030
]);
3131

32+
type Global = typeof globalThis & {
33+
process?: {
34+
env?: {
35+
CDN?: string;
36+
VERCEL?: string;
37+
};
38+
};
39+
};
40+
3241
function detectCDN(): CDN | undefined {
33-
if (globalThis?.process?.env?.CDN) {
34-
return globalThis.process.env.CDN as CDN;
42+
if ((globalThis as Global).process?.env?.CDN) {
43+
return (globalThis as Global).process.env.CDN as CDN;
3544
}
36-
if (globalThis?.process?.env.VERCEL) {
45+
if ((globalThis as Global).process?.env.VERCEL) {
3746
return "vercel";
3847
}
3948
if ("Netlify" in globalThis) {

fastly.test.js renamed to test/fastly.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// @ts-check
12
import assert from "node:assert";
23
import { describe, it } from "node:test";
3-
import { CacheHeaders } from "./dist/index.js";
4+
import { CacheHeaders } from "../dist/index.js";
45

56
describe("Fastly", () => {
67
it("merges cdn-cache-control header into cache-control", () => {

index.test.js renamed to test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
import assert from "node:assert";
33
import { describe, it } from "node:test";
4-
import { CacheHeaders, ONE_DAY } from "./dist/index.js";
4+
import { CacheHeaders, ONE_DAY } from "../dist/index.js";
55

66
describe("CacheHeaders", () => {
77
it("should append cache tags", () => {

netlify.test.js renamed to test/netlify.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from "node:assert";
22
import { describe, it } from "node:test";
3-
import { CacheHeaders } from "./dist/index.js";
3+
import { CacheHeaders } from "../dist/index.js";
44

55
describe("Netlify", () => {
66
it("sets tiered header on Netlify", () => {

0 commit comments

Comments
 (0)