forked from tsai/budibase
5 changed files with 22 additions and 29 deletions
@ -1,25 +1,20 @@ |
|||
const fs = require("fs") |
|||
const jimp = require("jimp") |
|||
const fsPromises = fs.promises |
|||
|
|||
const FORMATS = { |
|||
IMAGES: ["png", "jpg", "jpeg", "gif", "bmp", "tiff"], |
|||
} |
|||
|
|||
function processImage(file) { |
|||
// this will overwrite the temp file
|
|||
return jimp.read(file.path).then(img => { |
|||
return img.resize(300, jimp.AUTO).write(file.outputPath) |
|||
return img.resize(300, jimp.AUTO).write(file.path) |
|||
}) |
|||
} |
|||
|
|||
async function process(file) { |
|||
if (FORMATS.IMAGES.includes(file.extension.toLowerCase())) { |
|||
await processImage(file) |
|||
return file |
|||
} |
|||
|
|||
// No processing required
|
|||
await fsPromises.copyFile(file.path, file.outputPath) |
|||
return file |
|||
} |
|||
|
|||
@ -1,17 +0,0 @@ |
|||
const fs = require("fs-extra") |
|||
const { join } = require("./centralPath") |
|||
const os = require("os") |
|||
const fetch = require("node-fetch") |
|||
const stream = require("stream") |
|||
const tar = require("tar-fs") |
|||
const zlib = require("zlib") |
|||
const { promisify } = require("util") |
|||
const streamPipeline = promisify(stream.pipeline) |
|||
const { budibaseAppsDir } = require("./budibaseDir") |
|||
const env = require("../environment") |
|||
const { downloadTemplate } = require("./fileSystem") |
|||
|
|||
|
|||
// can't really test this, downloading is just not something we should do in a behavioural test
|
|||
/* istanbul ignore next */ |
|||
exports.downloadTemplate = downloadTemplate |
|||
Loading…
Reference in new issue