diff --git a/README.md b/README.md index 6c69ce4..a753eba 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # Fānyì (翻译) A 🇨🇳 and 🇺🇸🇬🇧 translator in your command line, powered by iciba and groq. +Ensure that the GROQ_API_KEY is set in your environment variables. [![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] diff --git a/bin/fanyi.mjs b/bin/fanyi.mjs index 60c22c5..25b0cdb 100755 --- a/bin/fanyi.mjs +++ b/bin/fanyi.mjs @@ -1,6 +1,8 @@ #!/usr/bin/env -S node --no-deprecation +import process from 'process'; import { readFile } from 'node:fs/promises'; + GROQ_API_KEY = process.env.GROQ_API_KEY, import chalk from 'chalk'; import { Command } from 'commander'; import updateNotifier from 'update-notifier'; diff --git a/index.mjs b/index.mjs index a4f36f2..caf572b 100644 --- a/index.mjs +++ b/index.mjs @@ -1,6 +1,8 @@ import { XMLParser } from 'fast-xml-parser'; +import process from 'process'; import gradient from 'gradient-string'; import { Groq } from 'groq-sdk'; + GROQ_API_KEY = process.env.GROQ_API_KEY, import fetch from 'node-fetch'; import ora from 'ora'; import { printIciba } from './lib/iciba.mjs'; diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index a8dc42f..0f664d5 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -1,4 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +Ensure that the GROQ_API_KEY is set in your environment variables. exports[`fanyi CLI > should print help if -h is given 1`] = ` "Usage: fanyi [options] [command]