import nanospawn in cjs interop way
Some checks failed
ci / build (push) Failing after 1s
ci / Tests & Checks (push) Failing after 1s

This commit is contained in:
CJ_Clippy 2025-07-16 22:44:15 -08:00
parent de09154fc8
commit 77b8fe75d9
2 changed files with 11 additions and 13 deletions

View File

@ -1,5 +1,4 @@
import type { Task, Helpers } from "graphile-worker";
import spawn from 'nano-spawn';
import { PrismaClient } from "../../generated/prisma";
import { withAccelerate } from "@prisma/extension-accelerate";
import { getOrDownloadAsset } from "../utils/cache";
@ -11,6 +10,7 @@ import { basename, join, dirname } from "node:path";
import { mkdirp } from "fs-extra";
import { listFilesRecursive } from "../utils/filesystem";
import { getMimeType } from "../utils/mimetype";
import { getNanoSpawn } from "../utils/nanoSpawn";
const prisma = new PrismaClient().$extends(withAccelerate());
@ -47,10 +47,12 @@ interface HlsVariant {
export async function createVariants(helpers: Helpers, inputFilePath: string): Promise<HlsVariant[]> {
const workdir = join(env.CACHE_ROOT, nanoid());
await mkdirp(workdir);
const baseName = basename(inputFilePath, '.mp4');
const spawn = await getNanoSpawn()
const resolutions = [
{ width: 1920, height: 1080, bitrate: 4000000, name: '1080p' }, // 4Mbps
@ -99,6 +101,7 @@ export async function packageHls(
): Promise<string> {
const args: string[] = [];
const spawn = await getNanoSpawn()
// Optional: sort variants by bandwidth descending
variants.sort((a, b) => b.bandwidth - a.bandwidth);
@ -123,18 +126,6 @@ export async function packageHls(
args.push('--segment_duration=2'); // matches Twitchs chunk size
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
helpers.logger.info(`PILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE\nPILLS HERE`)
await spawn('packager', args, {

View File

@ -0,0 +1,7 @@
// utils/nanoSpawn.ts
// we do this because we need to use dynamic import() when using ESM only module via tsup CJS interop.
export async function getNanoSpawn() {
const nanoSpawn = (await import('nano-spawn')).default;
return nanoSpawn
}