Skip to content

Commit 01c3672

Browse files
committed
1 parent 64044ec commit 01c3672

File tree

5 files changed

+96
-145
lines changed

5 files changed

+96
-145
lines changed

lib/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4981,16 +4981,17 @@ function run() {
49814981
}
49824982
// Collect assets to upload
49834983
{
4984-
const old_asset_map = {};
4985-
const in_delete_rule = {};
4984+
const old_asset_map = new Map();
4985+
const in_delete_rule = new Map();
49864986
if (is_verbose && delete_files_pattern) {
49874987
console.log(`Delete file pattern: ${delete_files_pattern}`);
49884988
}
49894989
if (deploy_release && deploy_release.data && deploy_release.data.assets) {
49904990
for (const asset of deploy_release.data.assets) {
4991-
old_asset_map[asset.name] = asset;
4991+
const asset_name_lc = asset.name.toLowerCase();
4992+
old_asset_map.set(asset_name_lc, asset);
49924993
if (delete_files_pattern && micromatch_1.default.isMatch(asset.name, delete_files_pattern)) {
4993-
in_delete_rule[asset.name] = true;
4994+
in_delete_rule.set(asset_name_lc, asset);
49944995
pending_to_delete.push(asset);
49954996
if (is_verbose) {
49964997
console.log(`Old asset file: ${asset.name} match ${delete_files_pattern}.`);
@@ -5000,13 +5001,14 @@ function run() {
50005001
}
50015002
for (const file_path of upload_files) {
50025003
const file_base_name = path.basename(file_path);
5003-
if (old_asset_map[file_base_name]) {
5004-
if (in_delete_rule[file_base_name]) {
5004+
const file_base_name_lc = file_base_name.toLowerCase();
5005+
if (old_asset_map.has(file_base_name_lc)) {
5006+
if (in_delete_rule.has(file_base_name_lc)) {
50055007
// Already in delete rule, do nothing.
50065008
console.log(`Overwrite asset file: ${file_base_name} , because it match ${delete_files_pattern}.`);
50075009
}
50085010
else if (is_overwrite) {
5009-
pending_to_delete.push(old_asset_map[file_base_name]);
5011+
pending_to_delete.push(old_asset_map[file_base_name_lc]);
50105012
pending_to_upload.push(file_path);
50115013
if (is_verbose) {
50125014
console.log(`Overwrite old asset file: ${file_base_name}.`);
@@ -14333,7 +14335,7 @@ const reduceIgnore = files => {
1433314335
const ensureAbsolutePathForCwd = (cwd, p) => {
1433414336
cwd = slash(cwd);
1433514337
if (path.isAbsolute(p)) {
14336-
if (p.startsWith(cwd)) {
14338+
if (slash(p).startsWith(cwd)) {
1433714339
return p;
1433814340
}
1433914341

lib/index.js.map

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "upload-to-github-release",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Github Action to deploy files to github release",
55
"main": "index.js",
66
"scripts": {
@@ -30,20 +30,20 @@
3030
"dependencies": {
3131
"@actions/core": "^1.2.6",
3232
"@actions/github": "^4.0.0",
33-
"globby": "^11.0.2",
33+
"globby": "^11.0.3",
3434
"micromatch": "^4.0.2",
3535
"mime": "^2.5.2",
3636
"string-env-interpolation": "^1.0.1",
37-
"type-fest": "^0.21.2"
37+
"type-fest": "^1.0.1"
3838
},
3939
"devDependencies": {
40-
"@types/jest": "^26.0.20",
41-
"@types/node": "^14.14.31",
40+
"@types/jest": "^26.0.22",
41+
"@types/node": "^14.14.37",
4242
"@zeit/ncc": "^0.22.3",
4343
"jest": "^26.6.3",
4444
"jest-circus": "^26.6.3",
45-
"ts-jest": "^26.5.2",
46-
"typescript": "^4.2.2",
47-
"npm-check-updates": "^11.1.8"
45+
"ts-jest": "^26.5.4",
46+
"typescript": "^4.2.3",
47+
"npm-check-updates": "^11.3.0"
4848
}
4949
}

src/index.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as fs from "fs";
77
import mime from "mime/lite";
88
// import Octokit from "@octokit/rest";
99
import { env } from "string-env-interpolation";
10-
import { AsyncReturnType, ValueOf } from "type-fest";
10+
import { AsyncReturnType, ValueOf, Except } from "type-fest";
1111

1212
// const io = require('@actions/io');
1313
// const tc = require('@actions/tool-cache');
@@ -525,8 +525,10 @@ async function run() {
525525

526526
// Collect assets to upload
527527
{
528-
const old_asset_map = {};
529-
const in_delete_rule = {};
528+
type DeployReleaseType = typeof deploy_release;
529+
type AssetType = Omit<Omit<Omit<DeployReleaseType, "data">, "assets">, 0>;
530+
const old_asset_map: Map<string, AssetType> = new Map<string, AssetType>();
531+
const in_delete_rule: Map<string, AssetType> = new Map<string, AssetType>();
530532

531533
if (is_verbose && delete_files_pattern) {
532534
console.log(
@@ -536,9 +538,10 @@ async function run() {
536538

537539
if (deploy_release && deploy_release.data && deploy_release.data.assets) {
538540
for (const asset of deploy_release.data.assets) {
539-
old_asset_map[asset.name] = asset;
541+
const asset_name_lc = asset.name.toLowerCase();
542+
old_asset_map.set(asset_name_lc, asset);
540543
if (delete_files_pattern && micromatch.isMatch(asset.name, delete_files_pattern)) {
541-
in_delete_rule[asset.name] = true;
544+
in_delete_rule.set(asset_name_lc, asset);
542545
pending_to_delete.push(asset);
543546

544547
if (is_verbose) {
@@ -552,14 +555,15 @@ async function run() {
552555

553556
for (const file_path of upload_files) {
554557
const file_base_name = path.basename(file_path);
555-
if (old_asset_map[file_base_name]) {
556-
if (in_delete_rule[file_base_name]) {
558+
const file_base_name_lc = file_base_name.toLowerCase();
559+
if (old_asset_map.has(file_base_name_lc)) {
560+
if (in_delete_rule.has(file_base_name_lc)) {
557561
// Already in delete rule, do nothing.
558562
console.log(
559563
`Overwrite asset file: ${file_base_name} , because it match ${delete_files_pattern}.`
560564
);
561565
} else if (is_overwrite) {
562-
pending_to_delete.push(old_asset_map[file_base_name]);
566+
pending_to_delete.push(old_asset_map[file_base_name_lc]);
563567
pending_to_upload.push(file_path);
564568

565569
if (is_verbose) {

0 commit comments

Comments
 (0)