Skip to content

Commit

Permalink
Remove undici dep
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow committed Jul 14, 2023
1 parent d3044b9 commit dfb149e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions packages/cli/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit dfb149e

Please sign in to comment.