UNPKG

@finn-no/cdn-uploader

Version:

Small tool uploading assets to CDN backend (Google Cloud Storage)

29 lines (22 loc) 657 B
const fs = require('fs'); const path = require('path'); const read = require('fs-readdir-recursive'); function makeAbsolute(filePath = '') { return path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath); } function isDirectory(dir) { try { return fs.lstatSync(dir).isDirectory(); } catch (err) { return false; } } function getFilesToUpload(assetsFolder, flatten) { return read(assetsFolder).map(file => ({ name: flatten ? path.basename(file) : file, path: path.join(assetsFolder, file), })); } module.exports = { makeAbsolute, isDirectory, getFilesToUpload };