INNER CODE UNIT · JavaScript
imagemin
imagemin/imagemin · index.js:46
export default async function imagemin(input, {glob = true, ...options} = {}) {
if (isBrowser) {
throw new Error('This package does not work in the browser.');
}
ow(input, ow.array);
const unixFilePaths = input.map(path => convertToUnixPath(path));
const filePaths = glob ? await globby(unixFilePaths, {onlyFiles: true}) : input;
return Promise.all(
filePaths
.filter(filePath => isNotJunk(path.basename(filePath)))
.map(async filePath => {
try {
return await handleFile(filePath, options);
} catch (error) {
error.message = `Error occurred when handling file: ${input}\n\n${error.stack}`;