Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings
vfile

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Return value ofrename in vfile-rename#75

Unanswered
webpro asked this question inQ&A
Discussion options

Thevfile-rename function works fine, but it was pretty subtle to me that the providedfile was not renamed:

const vFile = readSync(source);rename(vFile, {});

However, the returnedfile does include the rename and has the fullhistory:

vFile = rename(vFile, {});

Is this intentional? I'd think a rename would modify the passed file. Alternatively, I guess this should be documented more clearly.

You must be logged in to vote

Replies: 2 comments 3 replies

Comment options

Never mind, the implementation is fine, looks like no surprises here (https://github.com/vfile/vfile-rename/blob/main/index.js).

There is something very odd going on with my TypeScript setup. Sorry, feel free to close/delete this.

You must be logged in to vote
2 replies
@wooorm
Comment options

perhaps you have a version mismatch?readSync returns an instance of an old VFile class?

@wooorm
Comment options

That’s my guess, thathttps://github.com/vfile/vfile-rename/blob/103666cc3a5475df5e9382cdc209f17d1caead41/index.js#L44 is creating a new file

Comment options

Ah yes, that was probably it. Although I'm sure had the latest & greatest of all dependencies, I guess bothnpm link andnpm install --legacy-peer-deps may eventually result in mismatched versions somehow. Obviously I can't reproduce it anymore... Leaving the safety net here to avoid potential annoyances:https://github.com/webpro/markdown-rambler/blob/264f7b952098ae297fd97f7900fa911a91eddf4e/src/MarkdownRambler.ts#L185

Thanks for the swift response!

You must be logged in to vote
1 reply
@wooorm
Comment options

Ohh yeah linking unfortunately does that, I’ve had similar problems before. It’s one part of what I don’t like about TypeScript (which we now use everywhere). It forces the use ofinstanceof, which breaks across realms and classes, compared to the more resilient ducktyping that was in unified before :(

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@webpro@wooorm

[8]ページ先頭

©2009-2026 Movatter.jp