rstr74 / npmvc

PureMVC for node.js
4 stars 0 forks source link

Feature: Case sensitive check for cross platform path issues #2

Closed rstr74 closed 9 years ago

rstr74 commented 9 years ago

Some typo's can be hard to find in big project, maybe adding some sort of debugging mode in npmvc that enables this Case sensitive check.

sshams commented 9 years ago

Would be nice if the include statement can strictly check case mismatch for any path segment (file or folder name) even while developing on case insensitive environments to protect against typo bugs.

Suppose the actual path is: modules/speaker/view/components/Router

following statements should throw an error include("modules/speaker/view/components/router"); //error - router name mismatch include("modules/speaker/View/components/Router"); //error view name mismatch include("Modules/speaker/view/components/Router"); //error modules name mismatch

I'd prefer the feature to be as a default setting, shouldn't need a debugging mode for npmvc so we get our paths right in the first place to avoid deployment issues.

rstr74 commented 9 years ago

https://github.com/rstr74/npmvc/commit/59f842c1f98218c18eaf77e08cabf7c5e20e72ed

Work in progress and still on develop branch, did some thinking and added puremvc.validateIncludePaths option, when true; it checks if include Paths are correctly cased, when false(default) will ignore this (for now).

Have to test it out some more, but mainly it creates an error when the path and/or filename's does not match what is actual on the filesystem. The main reason not to go over to conventions, is that it has to accept filenames without UpperCase. Like index or some other exceptions where the include points to a module instead of a Class.

rstr74 commented 9 years ago

https://github.com/rstr74/npmvc/commit/c983ba63d8860119300593f9ea913c08467de5dd

I made two tests, https://github.com/rstr74/npmvc/blob/develop/test/validateIncludePathsDirectoryTest.js and https://github.com/rstr74/npmvc/blob/develop/test/validateIncludePathsFileTest.js

When setting puremvc.validateIncludePaths to true like this:

var puremvc = require("npmvc"); puremvc.validateIncludePaths = true;

It will produce warning like this for file typo's: [ PureMVC Include warning: Case sensitive warning for class or file: "/Users/XXXXXXX/npmvc/test/someComponent.js" doesn't exactly match the actual file path: "/Users/XXXXXXX/npmvc/test/SomeComponent.js"]

..or typo's in paths: [ PureMVC Include Path warning: Case sensitive warning in path: "/Users/XXXXXXX/npmvc/node_modules/some_npm_module/Some/path" Doesn't exactly match the actual directory path: "/Users/XXXXXXX/npmvc/node_modules/some_npm_module/some/path"]

rstr74 commented 9 years ago

published https://github.com/rstr74/npmvc/commit/af0d25c9aad1eb46c19227fa5356f593eeca39d3 npmvc 1.0.6-beta to npm

rstr74 commented 9 years ago

https://github.com/rstr74/npmvc/commit/1778933a2721c2f4eb8d722772fb5fa1e9c78d03 The puremvc.validateIncludePaths option only works on a mac, because it only works on a mac. But seriously, this is because other operation systems will fail and throws an error on the require call. On mac case sensitive typo's do not cause this, but will notice a typo AFTER the require call, and then outputs a warning.