build: convert code from CJS to ESM

This commit is contained in:
2025-03-21 01:59:26 -07:00
parent e6bde3e0de
commit 614a0a2daf

View File

@@ -1,16 +1,33 @@
#!/usr/bin/env node #!/usr/bin/env node
const fs = require('fs'); /*
const https = require('https'); Import Packages
const path = require('path'); */
const UserAgent = require('user-agents');
const http = require('http'); import os from 'os'
const os = require('os'); import fs from 'fs'
const zlib = require('zlib'); import https from 'https'
const { randomUUID } = require('crypto'); import path from 'path';
const { channel } = require('diagnostics_channel'); import UserAgent from 'user-agents';
import http from 'http'
import zlib from 'zlib'
import chalk from 'chalk';
const cache = new Map(); const cache = new Map();
/*
Import package.json values
*/
const { name, author, version, repository } = JSON.parse(fs.readFileSync('./package.json'));
/*
Old CJS variables converted to ESM
*/
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url); // get resolved path to file
const __dirname = path.dirname(__filename); // get name of directory
let URLS_FILE; let URLS_FILE;
let FORMATTED_FILE; let FORMATTED_FILE;
let EPG_FILE; let EPG_FILE;