-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement filename renaming library #3913
Conversation
072355e
to
e1c2ad9
Compare
It is a port of https://github.com/jonschlinkert/add-filename-increment for node.js into Kotlin, with some tweaks and tricks specific to Kotlin. Addresses TeamAmaze#2078
e1c2ad9
to
e039abf
Compare
Hi @TranceLove, I've noticed a couple of issues in your code:
|
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
Check and concatenate the extension (string that follows the final dot) only if it's not empty
@yatiksihag01 thanks for the feedback. Added c4ad60f to address the first issue, please take a look. But for the second problem... may you be more specific about the symptom(s) you have? Say when you call |
22c955f
to
1c0d7f7
Compare
} | ||
// Windows and default formatting are the same. | ||
else -> { | ||
if (n > 1) { |
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.
Here is the second problem. Let's say startArg
initial value is 1. When increment()
function initially call format()
, it'll simply return the same filename because n <= 1
. Then increment()
will call format()
for n = 2 and it'll work fine. I don't know if there's specific reason to add this if (n>1)
condition but in my case this is creating the problem.
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.
I think it's understandable, if looking at the unit test for windows.
Lines 40 to 48 in bda6148
fun testWindowsIncrementSimple() { | |
val pairs = arrayOf( | |
Pair("/test/file.txt", "/test/file (2).txt"), | |
Pair("sub/foo.txt", "sub/foo (2).txt"), | |
Pair("sub/nested/foo.txt", "sub/nested/foo (2).txt"), | |
Pair("/test/afile", "/test/afile (2)") | |
) | |
performTest(pairs, true) | |
} |
Couldn't comment if it's right or wrong, as I was doing a direct port... but if I understand correctly, looks like you'd want to have filenames from starting with file (2).txt
to file (1).txt
, which is different from the original node.js implementation.
If that is the case, see if 1f2cd85 fits your needs.
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.
Yes, now it's working fine.
Make increment starts from 1. So that in Windows/Default formatting scheme, the first incremented will begin with filenames like "file (1).txt" instead of "file (2).txt". Note: this behaviour is different from original node.js library
bda6148
to
1f2cd85
Compare
Description
It is a port of https://github.com/jonschlinkert/add-filename-increment for node.js into Kotlin, with some tweaks and tricks specific to Kotlin.
Issue tracker
Addresses #2078
Automatic tests
Manual tests
Build tasks success
Successfully running following tasks on local:
./gradlew assembledebug
./gradlew spotlessCheck
Related PR
Related to PR #3886