update test and run fmt/build

Signed-off-by: Rui Chen <rui@chenrui.dev>
This commit is contained in:
Rui Chen 2025-06-11 01:53:02 -04:00
parent edc85f0b7e
commit 18f874a13d
No known key found for this signature in database
GPG key ID: 6577287BDCA70840
4 changed files with 41 additions and 30 deletions

View file

@ -16,9 +16,9 @@ describe("util", () => {
it("strips template", () => { it("strips template", () => {
assert.equal( assert.equal(
uploadUrl( uploadUrl(
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}" "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
), ),
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets" "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets",
); );
}); });
}); });
@ -32,7 +32,7 @@ describe("util", () => {
it("parses newline and comma-delimited (and then some)", () => { it("parses newline and comma-delimited (and then some)", () => {
assert.deepStrictEqual( assert.deepStrictEqual(
parseInputFiles("foo,bar\nbaz,boom,\n\ndoom,loom "), parseInputFiles("foo,bar\nbaz,boom,\n\ndoom,loom "),
["foo", "bar", "baz", "boom", "doom", "loom"] ["foo", "bar", "baz", "boom", "doom", "loom"],
); );
}); });
}); });
@ -57,7 +57,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
}) }),
); );
}); });
it("uses input body path", () => { it("uses input body path", () => {
@ -80,7 +80,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
}) }),
); );
}); });
it("defaults to body path when both body and body path are provided", () => { it("defaults to body path when both body and body path are provided", () => {
@ -103,7 +103,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
}) }),
); );
}); });
}); });
@ -139,7 +139,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
@ -167,7 +167,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("supports discussion category names", () => { it("supports discussion category names", () => {
@ -187,13 +187,14 @@ describe("util", () => {
input_files: [], input_files: [],
input_preserve_order: undefined, input_preserve_order: undefined,
input_name: undefined, input_name: undefined,
input_overwrite_files: undefined,
input_tag_name: undefined, input_tag_name: undefined,
input_fail_on_unmatched_files: false, input_fail_on_unmatched_files: false,
input_target_commitish: undefined, input_target_commitish: undefined,
input_discussion_category_name: "releases", input_discussion_category_name: "releases",
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
@ -221,7 +222,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: true, input_generate_release_notes: true,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
@ -253,7 +254,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("uses input token as the source of GITHUB_TOKEN by default", () => { it("uses input token as the source of GITHUB_TOKEN by default", () => {
@ -282,7 +283,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("parses basic config with draft and prerelease", () => { it("parses basic config with draft and prerelease", () => {
@ -310,7 +311,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
it("parses basic config where make_latest is passed", () => { it("parses basic config where make_latest is passed", () => {
@ -330,13 +331,14 @@ describe("util", () => {
input_preserve_order: undefined, input_preserve_order: undefined,
input_files: [], input_files: [],
input_name: undefined, input_name: undefined,
input_overwrite_files: undefined,
input_tag_name: undefined, input_tag_name: undefined,
input_fail_on_unmatched_files: false, input_fail_on_unmatched_files: false,
input_target_commitish: undefined, input_target_commitish: undefined,
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: "false", input_make_latest: "false",
} },
); );
}); });
it("parses basic config with append_body", () => { it("parses basic config with append_body", () => {
@ -363,7 +365,7 @@ describe("util", () => {
input_discussion_category_name: undefined, input_discussion_category_name: undefined,
input_generate_release_notes: false, input_generate_release_notes: false,
input_make_latest: undefined, input_make_latest: undefined,
} },
); );
}); });
}); });
@ -380,7 +382,7 @@ describe("util", () => {
it("resolves files given a set of paths", async () => { it("resolves files given a set of paths", async () => {
assert.deepStrictEqual( assert.deepStrictEqual(
paths(["tests/data/**/*", "tests/data/does/not/exist/*"]), paths(["tests/data/**/*", "tests/data/does/not/exist/*"]),
["tests/data/foo/bar.txt"] ["tests/data/foo/bar.txt"],
); );
}); });
}); });
@ -389,7 +391,7 @@ describe("util", () => {
it("returns the patterns that don't match any files", async () => { it("returns the patterns that don't match any files", async () => {
assert.deepStrictEqual( assert.deepStrictEqual(
unmatchedPatterns(["tests/data/**/*", "tests/data/does/not/exist/*"]), unmatchedPatterns(["tests/data/**/*", "tests/data/does/not/exist/*"]),
["tests/data/does/not/exist/*"] ["tests/data/does/not/exist/*"],
); );
}); });
}); });
@ -401,7 +403,7 @@ describe("util", () => {
it("handles names with multiple spaces", () => { it("handles names with multiple spaces", () => {
expect(alignAssetName("John William Doe.bla")).toBe( expect(alignAssetName("John William Doe.bla")).toBe(
"John.William.Doe.bla" "John.William.Doe.bla",
); );
}); });

21
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -170,7 +170,7 @@ export const upload = async (
if (currentAsset) { if (currentAsset) {
if (config.input_overwrite_files === false) { if (config.input_overwrite_files === false) {
console.log( console.log(
`Asset ${name} already exists and overwrite_files is false...` `Asset ${name} already exists and overwrite_files is false...`,
); );
return null; return null;
} else { } else {

View file

@ -45,7 +45,7 @@ async function run() {
throttle: { throttle: {
onRateLimit: (retryAfter, options) => { onRateLimit: (retryAfter, options) => {
console.warn( console.warn(
`Request quota exhausted for request ${options.method} ${options.url}` `Request quota exhausted for request ${options.method} ${options.url}`,
); );
if (options.request.retryCount === 0) { if (options.request.retryCount === 0) {
// only retries once // only retries once
@ -56,7 +56,7 @@ async function run() {
onAbuseLimit: (retryAfter, options) => { onAbuseLimit: (retryAfter, options) => {
// does not retry, only logs a warning // does not retry, only logs a warning
console.warn( console.warn(
`Abuse detected for request ${options.method} ${options.url}` `Abuse detected for request ${options.method} ${options.url}`,
); );
}, },
}, },
@ -68,11 +68,11 @@ async function run() {
if (files.length == 0) { if (files.length == 0) {
if (config.input_fail_on_unmatched_files) { if (config.input_fail_on_unmatched_files) {
throw new Error( throw new Error(
`⚠️ ${config.input_files} does not include a valid file.` `⚠️ ${config.input_files} does not include a valid file.`,
); );
} else { } else {
console.warn( console.warn(
`🤔 ${config.input_files} does not include a valid file.` `🤔 ${config.input_files} does not include a valid file.`,
); );
} }
} }
@ -84,7 +84,7 @@ async function run() {
gh, gh,
uploadUrl(rel.upload_url), uploadUrl(rel.upload_url),
path, path,
currentAssets currentAssets,
); );
if (json) { if (json) {
delete json.uploader; delete json.uploader;