Fixed errors in Linter

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2021-06-29 23:19:12 +02:00
parent 0dc81b7657
commit a64f2e3d01
Signed by: Florian Bouillon
GPG Key ID: 50BD648F12C86AB6
2 changed files with 35 additions and 32 deletions

View File

@ -1,3 +1,4 @@
/* eslint-disable max-statements */
import { ConnectConfig, Client, SFTPWrapper } from 'ssh2'
import { Stats, InputAttributes } from 'ssh2-streams'
import { promises as fs } from 'fs'
@ -26,7 +27,7 @@ export default class SFTPPromise {
public constructor(public config: ConnectConfig) {}
public connect(): Promise<void> {
return new Promise<void>((res, rej) => {
return new Promise<void>((res) => {
this.conn.on('ready', () => {
this.conn.sftp((err, sftpLocal) => {
this.sftp = sftpLocal
@ -154,7 +155,7 @@ export default class SFTPPromise {
return res
}
public async uploadDir(localPath: string, remotePath: string, exclude?: RegExp, root = true) {
public async uploadDir(localPath: string, remotePath: string, exclude?: RegExp, root = true): Promise<void> {
if (root) {
this.filesToUpload = 0
this.filesUploaded = 0
@ -165,7 +166,7 @@ export default class SFTPPromise {
logger.log('Running !')
this.filesToUpload += files.length
this.queue.start()
for (const file of files) {
for await (const file of files) {
// console.log('t1')
if (exclude?.test(file)) {
continue
@ -200,6 +201,7 @@ export default class SFTPPromise {
return this.sftp
}
// eslint-disable-next-line id-length
private l(...messages: Array<any>) {
if (this.debug) {
logger.log(...messages)

21
main.ts
View File

@ -1,3 +1,4 @@
/* eslint-disable max-statements */
import { SupportedLanguages } from 'db/interfaces'
import { Endpoint } from 'interfaces'
import { promises as fs } from 'fs'
@ -17,15 +18,15 @@ const VERSION = 'v2'
console.log('Prefetching pictures')
await fetchRemoteFile('https://assets.tcgdex.net/datas.json')
await fs.rm(`./dist/${VERSION}/${lang}`, {recursive: true, force: true})
await fs.rm(`./dist/${VERSION}/${lang}`, { force: true, recursive: true })
console.log('Let\'s GO !')
for (const file of paths) {
for await (const file of paths) {
const path = `./endpoints/${file}`
console.log(file, 'Running Init')
const ep = (await import(path)).default
const endpoint = new ep(lang) as Endpoint
const Ep = (await import(path)).default
const endpoint = new Ep(lang) as Endpoint
console.log(file, 'Running Common')
let common: any | undefined = undefined
let common: any | null = null
if (endpoint.common) {
common = await endpoint.common()
}
@ -38,8 +39,11 @@ const VERSION = 'v2'
console.log(file, 'Finished Index')
console.log(file, 'Running Item')
const item = await endpoint.item(common)
if (item) {
for (const key of Object.keys(item)) {
if (!item) {
console.log(file, 'skipped Item')
continue
}
for await (const key of Object.keys(item)) {
const val = item[key]
const subFolder = `${folder}/${urlize(key)}`
await fs.mkdir(subFolder, { recursive: true })
@ -58,8 +62,5 @@ const VERSION = 'v2'
}
}
console.log(file, 'Finished Item')
} else {
console.log(file, 'skipped Item')
}
}
})()