filecoin-pin
Version:
Bridge IPFS content to Filecoin Onchain Cloud using familiar tools
27 lines • 899 B
JavaScript
import { stat } from 'node:fs/promises';
import { cleanupTempCar, createCarFromPath } from './car-builder.js';
export * from './car-builder.js';
export function createUnixfsCarBuilder() {
return {
async buildCar(sourcePath, options = {}) {
const { carPath, rootCid } = await createCarFromPath(sourcePath, options);
let size;
try {
const stats = await stat(carPath);
size = stats.size;
}
catch {
size = undefined;
}
const baseResult = {
carPath,
rootCid: rootCid.toString(),
};
return size !== undefined ? { ...baseResult, size } : baseResult;
},
async cleanup(carPath, logger) {
await cleanupTempCar(carPath, logger);
},
};
}
//# sourceMappingURL=index.js.map