diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 4e50762b..539feb52 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,7 +1,6 @@ module.exports = { extends: ['mifi'], rules: { - 'no-console': 0, 'jsx-a11y/click-events-have-key-events': 0, 'jsx-a11y/interactive-supports-focus': 0, 'jsx-a11y/control-has-associated-label': 0, @@ -15,6 +14,7 @@ module.exports = { browser: true, }, rules: { + 'no-console': 0, 'import/no-extraneous-dependencies': 0, }, }, @@ -23,6 +23,9 @@ module.exports = { env: { browser: true, }, + rules: { + 'no-console': 0, + }, }, { files: ['./script/**/*.{js,cjs,mjs,jsx,ts,tsx,mts}', 'electron.vite.config.ts'], diff --git a/script/xcrun-wrapper.mts b/script/xcrun-wrapper.mts index 924cdef1..9c341d16 100644 --- a/script/xcrun-wrapper.mts +++ b/script/xcrun-wrapper.mts @@ -1,4 +1,5 @@ // eslint-disable-line unicorn/filename-case +/* eslint-disable no-console */ import { execa } from 'execa'; import { readFile } from 'node:fs/promises'; diff --git a/src/main/compatPlayer.ts b/src/main/compatPlayer.ts index 5f34e3fa..0ee7fbd5 100644 --- a/src/main/compatPlayer.ts +++ b/src/main/compatPlayer.ts @@ -71,8 +71,8 @@ export function createMediaSourceStream({ path, videoStreamIndex, audioStreamInd // @ts-expect-error todo if (!(err.killed)) { // @ts-expect-error todo - console.warn(err.message); - console.warn(stderr.toString('utf8')); + logger.warn(err.message); + logger.warn(stderr.toString('utf8')); } } })(); diff --git a/src/main/ffmpeg.ts b/src/main/ffmpeg.ts index f62503d8..e234aed7 100644 --- a/src/main/ffmpeg.ts +++ b/src/main/ffmpeg.ts @@ -10,6 +10,7 @@ import { app } from 'electron'; import { platform, arch, isWindows, isMac, isLinux } from './util.js'; import { CaptureFormat, Html5ifyMode, Waveform } from '../../types.js'; import isDev from './isDev.js'; +import logger from './logger.js'; const runningFfmpegs = new Set>(); @@ -46,7 +47,7 @@ const getFfprobePath = () => getFfPath('ffprobe'); export const getFfmpegPath = () => getFfPath('ffmpeg'); export function abortFfmpegs() { - console.log('Aborting', runningFfmpegs.size, 'ffmpeg process(es)'); + logger.info('Aborting', runningFfmpegs.size, 'ffmpeg process(es)'); runningFfmpegs.forEach((process) => { process.kill('SIGTERM', { forceKillAfterTimeout: 10000 }); }); @@ -102,7 +103,7 @@ function handleProgress(process: { stderr: Readable | null }, durationIn: number onProgress(progress); } catch (err) { // @ts-expect-error todo - console.log('Failed to parse ffmpeg progress line:', err.message); + logger.error('Failed to parse ffmpeg progress line:', err.message); } }); } @@ -122,7 +123,7 @@ function getExecaOptions({ env, ...customExecaOptions }: Omit, 'encoding'>, additionalOptions?: { logCli?: boolean }) { const ffmpegPath = getFfmpegPath(); - if (additionalOptions?.logCli) console.log(getFfCommandLine('ffmpeg', args)); + if (additionalOptions?.logCli) logger.info(getFfCommandLine('ffmpeg', args)); const process = execa(ffmpegPath, args, getExecaOptions(customExecaOptions)); @@ -163,10 +164,10 @@ export async function runFfmpegWithProgress({ ffmpegArgs, duration, onProgress } export async function runFfprobe(args: readonly string[], { timeout = isDev ? 10000 : 30000 } = {}) { const ffprobePath = getFfprobePath(); - console.log(getFfCommandLine('ffprobe', args)); + logger.info(getFfCommandLine('ffprobe', args)); const ps = execa(ffprobePath, args, getExecaOptions()); const timer = setTimeout(() => { - console.warn('killing timed out ffprobe'); + logger.warn('killing timed out ffprobe'); ps.kill(); }, timeout); try { @@ -201,8 +202,8 @@ export async function renderWaveformPng({ filePath, start, duration, color, stre '-', ]; - console.log(getFfCommandLine('ffmpeg1', args1)); - console.log('|', getFfCommandLine('ffmpeg2', args2)); + logger.info(getFfCommandLine('ffmpeg1', args1)); + logger.info('|', getFfCommandLine('ffmpeg2', args2)); let ps1: ExecaChildProcess | undefined; let ps2: ExecaChildProcess | undefined; @@ -216,7 +217,7 @@ export async function renderWaveformPng({ filePath, start, duration, color, stre const timer = setTimeout(() => { ps1?.kill(); ps2?.kill(); - console.warn('ffmpeg timed out'); + logger.warn('ffmpeg timed out'); }, 10000); let stdout; @@ -453,7 +454,7 @@ export async function captureFrame({ timestamp, videoPath, outPath, quality }: { async function readFormatData(filePath: string) { - console.log('readFormatData', filePath); + logger.info('readFormatData', filePath); const { stdout } = await runFfprobe([ '-of', 'json', '-show_format', '-i', filePath, '-hide_banner', @@ -482,7 +483,7 @@ export async function html5ify({ outPath, filePath: filePathArg, speed, hasAudio else video = 'copy'; } - console.log('Making HTML5 friendly version', { filePathArg, outPath, speed, video, audio }); + logger.info('Making HTML5 friendly version', { filePathArg, outPath, speed, video, audio }); let videoArgs; let audioArgs; @@ -571,7 +572,7 @@ export async function html5ify({ outPath, filePath: filePathArg, speed, hasAudio if (duration) handleProgress(process, duration, onProgress); const { stdout } = await process; - console.log(stdout.toString('utf8')); + logger.info(stdout.toString('utf8')); } export function readOneJpegFrame({ path, seekTo, videoStreamIndex }: { path: string, seekTo: number, videoStreamIndex: number }) { @@ -658,7 +659,7 @@ export function createMediaSourceProcess({ path, videoStreamIndex, audioStreamIn '-f', 'mp4', '-movflags', '+frag_keyframe+empty_moov+default_base_moof', '-', ]; - if (enableLog) console.log(getFfCommandLine('ffmpeg', args)); + if (enableLog) logger.info(getFfCommandLine('ffmpeg', args)); return execa(getFfmpegPath(), args, { encoding: null, buffer: false, stderr: enableLog ? 'inherit' : 'pipe' }); }