Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/process-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ class ProcessLockManager {
}

// Ensure parent directory exists.
const lastSlash = lockPath.lastIndexOf('/')
const lastSlash = Math.max(
lockPath.lastIndexOf('/'),
lockPath.lastIndexOf('\\'),
)
if (lastSlash > 0) {
mkdirSync(lockPath.slice(0, lastSlash), { recursive: true })
}
Expand Down Expand Up @@ -328,7 +331,10 @@ class ProcessLockManager {

// Handle parent path issues - not retryable.
if (code === 'ENOTDIR') {
const lastSlashIndex = lockPath.lastIndexOf('/')
const lastSlashIndex = Math.max(
lockPath.lastIndexOf('/'),
lockPath.lastIndexOf('\\'),
)
const parentDir =
lastSlashIndex === -1 ? '.' : lockPath.slice(0, lastSlashIndex)
throw new Error(
Expand All @@ -344,7 +350,10 @@ class ProcessLockManager {
}

if (code === 'ENOENT') {
const lastSlashIndex = lockPath.lastIndexOf('/')
const lastSlashIndex = Math.max(
lockPath.lastIndexOf('/'),
lockPath.lastIndexOf('\\'),
)
const parentDir =
lastSlashIndex === -1 ? '.' : lockPath.slice(0, lastSlashIndex)
throw new Error(
Expand Down
6 changes: 5 additions & 1 deletion src/releases/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,11 @@ export async function getReleaseAssetUrl(
}

// Find the matching asset.
const asset = release.assets.find(a => isMatch(a.name))
const assets = release.assets
if (!Array.isArray(assets)) {
throw new Error(`Release ${tag} has no assets`)
}
const asset = assets.find(a => isMatch(a.name))

if (!asset) {
const patternDesc =
Expand Down
2 changes: 1 addition & 1 deletion test/unit/releases-github.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ describe('releases/github', () => {
})

it('should throw error when pattern does not match any asset', async () => {
vi.mocked(httpRequest).mockResolvedValueOnce(
vi.mocked(httpRequest).mockResolvedValue(
createMockHttpResponse(
Buffer.from(JSON.stringify(mockRelease)),
true,
Expand Down
Loading