Skip to content

Commit 212f125

Browse files
committed
fix: normalize dest path
1 parent fc71f5a commit 212f125

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ async function run(): Promise<void> {
99
const bucket = core.getInput('bucket');
1010
const sourceDir = core.getInput('source_dir');
1111
const destDir = core.getInput('dest_dir');
12-
const ignoreSourceMap = core.getInput('ignore_source_map');
12+
const ignoreSourceMap = core.getInput('ignore_source_map') === 'true';
1313

1414
const token = genToken(bucket, ak, sk);
1515

1616
upload(
1717
token,
1818
sourceDir,
1919
destDir,
20-
Boolean(ignoreSourceMap),
21-
(file, key) => core.info(`success: ${file} => ${key}`),
20+
ignoreSourceMap,
21+
(file, key) => core.info(`success: ${file} => [${bucket}]: ${key}`),
2222
() => core.info('Done!'),
2323
(error) => core.setFailed(error.message),
2424
);

src/upload.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import glob from 'glob';
44
import pAll from 'p-all';
55
import pRetry from 'p-retry';
66

7+
function normalizePath(input: string): string {
8+
let val = input.replace(/^\//, '');
9+
if (!val.endsWith('/')) {
10+
val += '/';
11+
}
12+
return val;
13+
}
14+
715
export function upload(
816
token: string,
917
srcDir: string,
@@ -22,7 +30,7 @@ export function upload(
2230

2331
const tasks = files.map((file) => {
2432
const relativePath = path.relative(baseDir, path.dirname(file));
25-
const key = path.join(destDir, relativePath, path.basename(file));
33+
const key = normalizePath(path.join(destDir, relativePath, path.basename(file)));
2634

2735
if (ignoreSourceMap && file.endsWith('.map')) return null;
2836

0 commit comments

Comments
 (0)