21 lines
764 B
TypeScript
21 lines
764 B
TypeScript
import * as plugins from './plugins.js';
|
|
import * as paths from './paths.js';
|
|
|
|
export const fileUrls = {
|
|
dockerAlpineImage: 'https://code.foss.global/testassets/docker/raw/branch/main/alpine.tar',
|
|
}
|
|
|
|
export class TestFileProvider {
|
|
public async getDockerAlpineImageAsLocalTarball(): Promise<string> {
|
|
const filePath = plugins.path.join(paths.testFilesDir, 'alpine.tar')
|
|
// fetch the docker alpine image
|
|
const response = await plugins.smartrequest.SmartRequest.create()
|
|
.url(fileUrls.dockerAlpineImage)
|
|
.get();
|
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
await plugins.fs.promises.mkdir(paths.testFilesDir, { recursive: true });
|
|
await plugins.fs.promises.writeFile(filePath, buffer);
|
|
return filePath;
|
|
}
|
|
}
|