feat: rating for dishes

This commit is contained in:
2023-07-18 14:24:15 +02:00
parent 2fe8275f2f
commit c9240f289e
21 changed files with 534 additions and 31 deletions

View File

@@ -12,21 +12,16 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import glob from 'glob';
import {glob} from 'glob';
import {readFileSync} from 'fs';
import {matchPropertyContent, matchTagProperties} from '../src/app/util/ion-icon/icon-match';
const globPromise = (pattern: string) =>
new Promise<string[]>((resolve, reject) =>
glob(pattern, (error, files) => (error ? reject(error) : resolve(files))),
);
/**
*
*/
export async function getUsedIconsHtml(glob = 'src/**/*.html'): Promise<Record<string, string[]>> {
export async function getUsedIconsHtml(pattern = 'src/**/*.html'): Promise<Record<string, string[]>> {
return Object.fromEntries(
(await globPromise(glob))
(await glob(pattern))
.map(file => [
file,
(readFileSync(file, 'utf8')
@@ -43,9 +38,9 @@ export async function getUsedIconsHtml(glob = 'src/**/*.html'): Promise<Record<s
/**
*
*/
export async function getUsedIconsTS(glob = 'src/**/*.ts'): Promise<Record<string, string[]>> {
export async function getUsedIconsTS(pattern = 'src/**/*.ts'): Promise<Record<string, string[]>> {
return Object.fromEntries(
(await globPromise(glob))
(await glob(pattern))
.map(file => [file, readFileSync(file, 'utf8').match(/(?<=Icon`)[\w-]+(?=`)/g) || []])
.filter(([, values]) => values.length > 0),
);