MCPcopy Create free account
hub / github.com/api-platform/website / createColouringMiniatures

Function createColouringMiniatures

pwa/prebuild.js:81–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81async function createColouringMiniatures() {
82 const inputDirectory = path.join(
83 process.cwd(),
84 "public",
85 "images",
86 "colouring"
87 );
88 const filenames = fs.readdirSync(inputDirectory);
89
90 await Promise.all(
91 filenames
92 .filter((file: string) => path.parse(file).ext === ".jpg")
93 .map(async (file: string) => {
94 const outputFile = `${inputDirectory}/mini/${
95 path.parse(file).name
96 }.jpg`;
97 if (fs.existsSync(outputFile)) {
98 // File exists in path
99 } else {
100 await sharp(`${inputDirectory}/${file}`)
101 .resize(500, undefined)
102 .toFormat("jpg")
103 .toFile(outputFile);
104 }
105 })
106 );
107}
108
109const checkStatus = (response: any) => {
110 if (response.ok) {

Callers 1

prebuild.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected