volojs / volo

Create front end projects from templates, add dependencies, and automate the resulting projects
https://volojs.github.io/
Other
1.41k stars 100 forks source link

Strange behavior with casing #196

Closed jbblanchet closed 9 years ago

jbblanchet commented 9 years ago

I'm using volo to download typescript definition files, which may or may not be supported, but still works fine. But I've encountered a strange behavior with the casing.

When using this command, everything works great and I get my Q.d.ts file in my defs subdirectory:

C:\GitHub\WonderfulProject>volo add borisyankov/DefinitelyTyped#q/Q.d.ts defs/Q.d
Downloading: https://raw.githubusercontent.com/borisyankov/DefinitelyTyped/master/q/Q.d.ts
Installed github:borisyankov/DefinitelyTyped/master#q/Q.d.ts at lib\defs\Q.d.ts

But when not using the capital Q, the file still gets downloaded, but is renamed q.d.js instead of ts:

C:\GitHub\WonderfulProject>volo add borisyankov/DefinitelyTyped#q/q.d.ts defs/q.d
Downloading: https://codeload.github.com/borisyankov/DefinitelyTyped/legacy.zip/master
Installed github:borisyankov/DefinitelyTyped/master#q/q.d.ts at lib\defs\q.d.js

This is not at all a major problem as all I have to do is watch my casing, but it still looks like a bug.

jrburke commented 9 years ago

I do not recall for sure, but is DOS/Windows shell case insensitive? So a cd A and cd a both work for a directory called A? If so, then this is just a limitation of case insensitive shells or file systems. Since the command worked, then it seems like the file system/shell allowed the names to match. I am not even sure what solution that would work to get any real casing. If the shell/file system allows the file selection by the lower case name, I think this is just a limitation of the environment.

So will close as such. However, feel free to continue discussion here.

jbblanchet commented 9 years ago

Windows (and large parts of the web) is indeed case-insensitive. But while case sensitivity impacts the lookup, it's the renaming part that I'm not sure should happen.

The second add cannot find the file at raw.githubusercontent.com because that URL is case sensitive (probably because it's simply a proxy for a *nix file system), so it gets the zip from the codeload.github.com site and unzips it, then finds the file in there because the OS is case-insensitive. So far so good.

What I don't understand is why the extension is changed. My guess is that you're comparing the "package name" with the file name, without the extension but with case-sensitivity, and if they don't match you rename the file. So since in the first case Q.d matches Q.d, nothing is renamed, but in the second case q.d !== Q.d, so it is renamed. So far, still so good. But in the renaming, the extension is changed, and I can't understand why. I'm fine with Q.d.ts being renamed q.d.ts, but not q.d.js.

I understand this is an extreme case. I'm using Volo to get TypeScript definitions files (which it's not built to do), I made a mistake in the casing, and I'm using Windows. But I'm still not sure if the extension should be changed.