forked from satackey/action-docker-layer-caching
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
13 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
import { assertType } from 'typescript-is' | ||
import { promises as fs } from 'fs' | ||
import * as path from 'path' | ||
import { promises as fs } from "fs"; | ||
import * as path from "path"; | ||
|
||
export interface Manifest { | ||
Config: string | ||
RepoTags: string[] | null | ||
Layers: string[] | ||
Config: string; | ||
RepoTags: string[] | null; | ||
Layers: string[]; | ||
} | ||
|
||
export type Manifests = Manifest[] | ||
|
||
export function assertManifests(x: unknown): asserts x is Manifests { | ||
assertType<Manifests>(x) | ||
} | ||
export type Manifests = Manifest[]; | ||
|
||
export async function loadRawManifests(rootPath: string) { | ||
return (await fs.readFile(path.join(rootPath, `manifest.json`))).toString() | ||
return (await fs.readFile(path.join(rootPath, `manifest.json`))).toString(); | ||
} | ||
|
||
export async function loadManifests(path: string) { | ||
const raw = await loadRawManifests(path) | ||
const manifests = JSON.parse(raw.toString()) | ||
assertManifests(manifests) | ||
return manifests | ||
const raw = await loadRawManifests(path); | ||
const manifests = JSON.parse(raw.toString()); | ||
return manifests; | ||
} |