mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-08-02 20:51:57 +00:00
fix: error while compiling on Windows (#846)
This commit is contained in:
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
@@ -10,7 +10,10 @@ on:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable sort-keys */
|
||||
import { exec } from 'child_process'
|
||||
import pathLib from 'node:path'
|
||||
import { Card, Set, SupportedLanguages, Types } from '../../../interfaces'
|
||||
import { CardResume, Card as CardSingle } from '../../../meta/definitions/api'
|
||||
import { getSet, setToSetSimple } from './setUtil'
|
||||
@@ -145,7 +145,7 @@ export async function getCards(lang: SupportedLanguages, set?: Set): Promise<Arr
|
||||
}
|
||||
const list: Array<[string, Card]> = []
|
||||
for (const path of cards) {
|
||||
let items = path.split('/')
|
||||
let items = path.split(pathLib.sep)
|
||||
items = items.slice(items.length - 3)
|
||||
|
||||
// get the card id
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import path from 'node:path'
|
||||
import { Serie, Set, SupportedLanguages } from '../../../interfaces'
|
||||
import { SerieResume, Serie as SerieSingle } from '../../../meta/definitions/api'
|
||||
import { getSets, setToSetSimple } from './setUtil'
|
||||
@@ -17,6 +18,7 @@ export async function isSerieAvailable(serie: Serie, lang: SupportedLanguages):
|
||||
|
||||
export async function getSeries(lang: SupportedLanguages): Promise<Array<Serie>> {
|
||||
let series: Array<Serie> = (await Promise.all((await smartGlob(`${DB_PATH}/${getDataFolder(lang)}/*.ts`))
|
||||
.map((it) => it.replaceAll(path.sep, '/'))
|
||||
// Find Serie's name
|
||||
.map((it) => it.substring(it.lastIndexOf('/') + 1, it.length - 3))
|
||||
// Fetch the Serie
|
||||
|
@@ -3,6 +3,7 @@ import { Set, SupportedLanguages } from '../../../interfaces'
|
||||
import { SetResume, Set as SetSingle } from '../../../meta/definitions/api'
|
||||
import { cardToCardSimple, getCards } from './cardUtil'
|
||||
import { DB_PATH, fetchRemoteFile, getDataFolder, resolveText, setIsLegal, smartGlob } from './util'
|
||||
import path from 'node:path'
|
||||
|
||||
interface t {
|
||||
[key: string]: Set
|
||||
@@ -37,7 +38,9 @@ export async function getSet(name: string, serie = '*', lang: SupportedLanguages
|
||||
// Dont use cache as it wont necessary have them all
|
||||
export async function getSets(serie = '*', lang: SupportedLanguages): Promise<Array<Set>> {
|
||||
// list sets names
|
||||
const rawSets = (await smartGlob(`${DB_PATH}/${getDataFolder(lang)}/${serie}/*.ts`)).map((set) => set.substring(set.lastIndexOf('/') + 1, set.lastIndexOf('.')))
|
||||
const rawSets = (await smartGlob(`${DB_PATH}/${getDataFolder(lang)}/${serie}/*.ts`))
|
||||
.map((it) => it.replaceAll(path.sep, '/'))
|
||||
.map((set) => set.substring(set.lastIndexOf('/') + 1, set.lastIndexOf('.')))
|
||||
// Fetch sets
|
||||
const sets = (await Promise.all(rawSets.map((set) => getSet(set, serie, lang))))
|
||||
// Filter sets
|
||||
|
@@ -5,7 +5,6 @@ import { exec, spawn } from 'node:child_process'
|
||||
import { writeFileSync } from 'node:fs'
|
||||
import { Card, Languages, Set, SupportedLanguages } from '../../../interfaces'
|
||||
import * as legals from '../../../meta/legals'
|
||||
|
||||
interface fileCacheInterface {
|
||||
[key: string]: any
|
||||
}
|
||||
@@ -140,7 +139,8 @@ export async function loadLastEdits() {
|
||||
console.log('Loaded files tree', files.length, 'files')
|
||||
console.log('Loading their last edit time')
|
||||
let processed = 0
|
||||
const queue = new Queue(1000, 10)
|
||||
const concurrent = process.platform === 'win32' ? 10 : 1000
|
||||
const queue = new Queue(concurrent, 10)
|
||||
queue.start()
|
||||
|
||||
for await (let file of files) {
|
||||
|
Reference in New Issue
Block a user