From 5ca0675ebf9f0e50ce19fd47508fd6c18aa3aec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Tue, 15 Aug 2023 11:30:54 +0200 Subject: [PATCH] actually fix glob call --- packages/rollup-plugin-copy/src/listFiles.js | 24 ++++++------------- .../src/input/getInputData.ts | 2 +- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/packages/rollup-plugin-copy/src/listFiles.js b/packages/rollup-plugin-copy/src/listFiles.js index 2118ef0c9..11f96aa42 100644 --- a/packages/rollup-plugin-copy/src/listFiles.js +++ b/packages/rollup-plugin-copy/src/listFiles.js @@ -10,24 +10,14 @@ const path = require('path'); * @param {string} fromGlob * @param {string} rootDir * @param {string|string[]} [ignore] + * + * @returns Promise */ -function listFiles(fromGlob, rootDir, ignore) { - return new Promise(resolve => { - glob.sync(fromGlob, { cwd: rootDir, dot: true, ignore }, (er, files) => { - // remember, each filepath returned is relative to rootDir - resolve( - files - .map( - /** @param {string} filePath */ - filePath => path.resolve(rootDir, filePath), - ) - .filter( - /** @param {string} filePath */ - filePath => !fs.lstatSync(filePath).isDirectory(), - ), - ); - }); - }); +async function listFiles(fromGlob, rootDir, ignore) { + const files = await glob(fromGlob, { cwd: rootDir, dot: true, ignore }); + return files + .map(filePath => path.resolve(rootDir, filePath)) + .filter(filePath => !fs.lstatSync(filePath).isDirectory()); } module.exports = { listFiles }; diff --git a/packages/rollup-plugin-html/src/input/getInputData.ts b/packages/rollup-plugin-html/src/input/getInputData.ts index 52792de2d..d37aa6473 100644 --- a/packages/rollup-plugin-html/src/input/getInputData.ts +++ b/packages/rollup-plugin-html/src/input/getInputData.ts @@ -1,7 +1,7 @@ import fs from 'fs'; import path from 'path'; import glob from 'glob'; -import type {GlobOptions} from 'glob'; +import type { GlobOptions } from 'glob'; import { createError } from '../utils'; import { RollupPluginHTMLOptions } from '../RollupPluginHTMLOptions';