-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrom-download.ts
More file actions
42 lines (37 loc) · 1.05 KB
/
Copy pathfrom-download.ts
File metadata and controls
42 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file `synpFromDownload()` — installs the pinned synp npm package via
* `dlx/package` and returns a `ResolvedSynp` pointing at the resolved bin
* shim.
*/
import { downloadNpmPackage } from '../../dlx/package'
import { getSynpPackageSpec } from './asset-names'
import type { ResolvedSynp } from './types'
export interface SynpFromDownloadOptions {
/**
* Synp release version, e.g. `'1.9.14'`.
*/
version: string
/**
* Optional SRI integrity (e.g. `sha512-...`). When set, dlx verifies the
* downloaded tarball against this hash.
*/
integrity?: string | undefined
}
export async function synpFromDownload(
options: SynpFromDownloadOptions,
): Promise<ResolvedSynp> {
const { integrity, version } = {
__proto__: null,
...options,
} as typeof options
const packageSpec = getSynpPackageSpec({ version })
const { binaryPath } = await downloadNpmPackage({
spec: packageSpec,
binaryName: 'synp',
...(integrity ? { hash: integrity } : {}),
})
return {
path: binaryPath,
source: 'download',
}
}