mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
misc: convert all internal scripts to ESM (#6286)
* misc: convert all internal scripts to ESM * fixes * fix * fixes * fix! * complete eslint * more move * fix! * This looks better? * Final ones
This commit is contained in:
parent
bcc05e243f
commit
4fad1ce0cd
66 changed files with 412 additions and 374 deletions
|
@ -5,26 +5,26 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
|
||||
import sharp from 'sharp';
|
||||
import fs from 'fs/promises';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import imageSize from 'image-size';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
const allImages = (
|
||||
await fs.readdir(new URL('../../website/src/data/showcase', import.meta.url))
|
||||
).filter((file) => ['.png', 'jpg', '.jpeg'].includes(path.extname(file)));
|
||||
|
||||
const [,,...selectedImages] = process.argv;
|
||||
const [, , ...selectedImages] = process.argv;
|
||||
const images = selectedImages.length > 0 ? selectedImages : allImages;
|
||||
|
||||
await Promise.all(
|
||||
images.map(async (img) => {
|
||||
const imgPath = new URL(
|
||||
`../../website/src/data/showcase/${img}`,
|
||||
import.meta.url,
|
||||
).pathname;
|
||||
const imgPath = fileURLToPath(
|
||||
new URL(`../../website/src/data/showcase/${img}`, import.meta.url),
|
||||
);
|
||||
const {width, height} = imageSize(imgPath);
|
||||
if (width === 640 && height === 320) {
|
||||
// Do not emit if no resized. Important because we
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue