Files
tstest/ts_tapbundle_node/classes.testfileprovider.ts

20 lines
747 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();
await plugins.smartfile.fs.ensureDir(paths.testFilesDir);
const buffer = Buffer.from(await response.arrayBuffer());
await plugins.smartfile.memory.toFs(buffer, filePath);
return filePath;
}
}