From dfb149e9603e3f115eb69a9825bfc5552431a48c Mon Sep 17 00:00:00 2001 From: Drew Powers Date: Fri, 14 Jul 2023 14:17:47 -0600 Subject: [PATCH] Remove undici dep --- packages/cli/bin/cli.js | 8 +++----- packages/cli/package.json | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/cli/bin/cli.js b/packages/cli/bin/cli.js index 2430560d..2cfbddee 100755 --- a/packages/cli/bin/cli.js +++ b/packages/cli/bin/cli.js @@ -9,10 +9,8 @@ import {parse} from '@cobalt-ui/core'; import {DIM, FG_BLUE, FG_RED, FG_GREEN, FG_YELLOW, UNDERLINE, RESET} from '@cobalt-ui/utils'; import chokidar from 'chokidar'; import fs from 'node:fs'; -import path from 'node:path'; import {performance} from 'node:perf_hooks'; import yaml from 'js-yaml'; -import undici from 'undici'; import {fileURLToPath, URL} from 'node:url'; import parser from 'yargs-parser'; import {init as initConfig} from '../dist/config.js'; @@ -210,11 +208,11 @@ async function loadTokens(tokenPaths) { // download/read for (const filepath of tokenPaths) { - const ext = path.extname(filepath.pathname); - const isYAMLExt = ext === '.yaml' || ext === '.yml'; + const pathname = filepath.pathname.toLowerCase(); + const isYAMLExt = pathname.endsWith('.yaml') || pathname.endsWith('.yml'); if (filepath.protocol === 'url:') { try { - const raw = await undici.fetch(filepath, {method: 'GET', headers: {Accepted: '*/*', 'User-Agent': 'cobalt'}}).then((res) => res.text()); + const raw = await globalThis.fetch(filepath, {method: 'GET', headers: {Accepted: '*/*', 'User-Agent': 'cobalt'}}).then((res) => res.text()); if (isYAMLExt || res.headers.get('content-type').includes('yaml')) { rawTokens.push(yaml.load(raw)); } else { diff --git a/packages/cli/package.json b/packages/cli/package.json index 140cf090..1c13afd1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -45,7 +45,6 @@ "js-yaml": "^4.1.0", "piscina": "^3.2.0", "svgo": "^3.0.2", - "undici": "^5.22.1", "yargs-parser": "^21.1.1" }, "devDependencies": {