-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(download): show saved file path in web read and weixin download output #1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cbfbbe9
b33c898
48b1f07
40d2820
c13b8dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import * as fs from 'node:fs'; | ||
| import * as os from 'node:os'; | ||
| import * as path from 'node:path'; | ||
| import { afterEach, describe, expect, it } from 'vitest'; | ||
| import { downloadArticle } from './article-download.js'; | ||
|
|
||
| const tempDirs: string[] = []; | ||
|
|
||
| afterEach(() => { | ||
| for (const dir of tempDirs) { | ||
| try { | ||
| fs.rmSync(dir, { recursive: true, force: true }); | ||
| } catch { | ||
| // Ignore cleanup errors in tests. | ||
| } | ||
| } | ||
| tempDirs.length = 0; | ||
| }); | ||
|
|
||
| describe('downloadArticle', () => { | ||
| it('returns the saved markdown file path on success', async () => { | ||
| const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'opencli-article-')); | ||
| tempDirs.push(tempDir); | ||
|
|
||
| const result = await downloadArticle({ | ||
| title: 'Test Article', | ||
| author: 'Author', | ||
| publishTime: '2026-04-20 12:00:00', | ||
| sourceUrl: 'https://example.com/article', | ||
| contentHtml: '<p>Hello world</p>', | ||
| }, { | ||
| output: tempDir, | ||
| downloadImages: false, | ||
| }); | ||
|
|
||
| expect(result).toHaveLength(1); | ||
| expect(result[0].status).toBe('success'); | ||
| expect(result[0].saved).toMatch(new RegExp(`^${tempDir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`)); | ||
| expect(path.extname(result[0].saved)).toBe('.md'); | ||
| expect(fs.existsSync(result[0].saved)).toBe(true); | ||
| expect(fs.readFileSync(result[0].saved, 'utf8')).toContain('Hello world'); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,7 @@ export interface ArticleDownloadResult { | |||||
| publish_time: string; | ||||||
| status: string; | ||||||
| size: string; | ||||||
| saved: string; | ||||||
|
||||||
| saved: string; | |
| saved?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
columnsadds the newsavedfield, but not all return paths in this command include it. In particular, the invalid-URL early return a few lines below returns an object withoutsaved, which makes output schema inconsistent. Update that return object to includesaved: '-'as well.