Skip to content

Commit

Permalink
Fix missing function
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Mar 15, 2023
1 parent ceb0855 commit ab0ada3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actions/upload/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ args:

import { S3, S3Bucket } from "s3"
import { pkg as pkgutils } from "utils"
import { useCache, useFlags, useOffLicense, usePrefix } from "hooks"
import { useFlags, useOffLicense, usePrefix } from "hooks"
import { Package, PackageRequirement } from "types"
import SemVer, * as semver from "semver"
import { basename, dirname } from "deno/path/mod.ts"
Expand All @@ -21,6 +21,7 @@ import { decode as base64Decode } from "deno/encoding/base64.ts"
import Path from "path"
import { set_output } from "../utils/gha.ts"
import { sha256 } from "../bottle/bottle.ts"
import useCache from "../../lib/useCache.ts"

//------------------------------------------------------------------------- funcs
function args_get(key: string): string[] {
Expand Down
36 changes: 36 additions & 0 deletions lib/useCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Stowed, SupportedArchitecture, SupportedPlatform } from "types"
import SemVer from "semver"
import Path from "path"

export default function() {
return { decode }
}

function decode(path: Path): Stowed | undefined {
const match = path.basename().match(`^(.*)-(\\d+\\.\\d+\\.\\d+.*?)(\\+(.+?)\\+(.+?))?\\.tar\\.[gx]z$`)
if (!match) return
const [_, p, v, host, platform, arch] = match
// Gotta undo the package name manipulation to get the package from the bottle
const project = p.replaceAll("∕", "/")
const version = new SemVer(v)
if (!version) return
const pkg = { project, version }
if (host) {
const compression = path.extname() == '.tar.gz' ? 'gz' : 'xz'
return {
pkg,
type: 'bottle',
host: {
platform: platform as SupportedPlatform,
arch: arch as SupportedArchitecture
},
compression,
path
}
} else {
return {
pkg, type: 'src', path,
extname: path.extname(),
}
}
}

0 comments on commit ab0ada3

Please sign in to comment.