diff --git a/packages/cache/__tests__/cacheUtils.test.ts b/packages/cache/__tests__/cacheUtils.test.ts index f1f95577..c5817f2d 100644 --- a/packages/cache/__tests__/cacheUtils.test.ts +++ b/packages/cache/__tests__/cacheUtils.test.ts @@ -32,3 +32,8 @@ test('assertDefined throws if undefined', () => { test('assertDefined returns value', () => { expect(cacheUtils.assertDefined('test', 5)).toBe(5) }) + +test('resolvePaths works on current directory', async () => { + const resolvedPath = await cacheUtils.resolvePaths(['.']) + expect(resolvedPath).toBe(['.']) +}) diff --git a/packages/cache/src/internal/cacheUtils.ts b/packages/cache/src/internal/cacheUtils.ts index 9c1035a9..f2eb436a 100644 --- a/packages/cache/src/internal/cacheUtils.ts +++ b/packages/cache/src/internal/cacheUtils.ts @@ -52,7 +52,12 @@ export async function resolvePaths(patterns: string[]): Promise { .replace(new RegExp(`\\${path.sep}`, 'g'), '/') core.debug(`Matched: ${relativeFile}`) // Paths are made relative so the tar entries are all relative to the root of the workspace. - paths.push(`${relativeFile}`) + if (relativeFile === "") { + // path.relative returns empty string if workspace and file are equal + paths.push(".") + } else { + paths.push(`${relativeFile}`) + } } return paths