Skip to content

Commit

Permalink
Handle situations where user has CDed into incorrectly cased directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Urthen committed Sep 6, 2016
1 parent 21390e1 commit d02babf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
34 changes: 21 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
/* This plugin based on https://gist.github.com/Morhaus/333579c2a5b4db644bd5
Original license:
--------
Original license:
--------
The MIT License (MIT)
Copyright (c) 2015 Alexandre Kirszenberg
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------
--------
And it's NPM-ified version: https://github.com/dcousineau/force-case-sensitivity-webpack-plugin
Author Daniel Cousineau indicated MIT license as well but did not include it
And it's NPM-ified version: https://github.com/dcousineau/force-case-sensitivity-webpack-plugin
Author Daniel Cousineau indicated MIT license as well but did not include it
The originals did not properly case-sensitize the entire path, however. This plugin resolves that issue.
The originals did not properly case-sensitize the entire path, however. This plugin resolves that issue.
This plugin license, also MIT:
--------
This plugin license, also MIT:
--------
The MIT License (MIT)
Copyright (c) 2016 Michael Pratt
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------
*/
--------
*/

var path = require('path');
var fs = require('fs');

function CaseSensitivePathsPlugin(options) {
this.options = options || {};
this.reset();
}

CaseSensitivePathsPlugin.prototype.reset = function () {
// Keep cache of filesystem contents along path reduce FS operations
this.pathCache = {};
this.fsOperations = 0;
this.options = options || {};

// Prime the cache with the current directory. We have to assume the current casing is correct,
// as in certain circumstances people can switch into an incorrectly-cased directory.
var currentPath = path.resolve();
this.pathCache[currentPath] = this.getFilenamesInDir(currentPath);
}

CaseSensitivePathsPlugin.prototype.getFilenamesInDir = function (dir) {
Expand Down Expand Up @@ -103,8 +112,7 @@ CaseSensitivePathsPlugin.prototype.apply = function(compiler) {
if (_this.options.debug) {
console.log('[CaseSensitivePathsPlugin] Total filesystem reads:', _this.fsOperations);
}
_this.pathCache = {};
_this.fsOperations = 0;
_this.reset();
});

compiler.plugin('normal-module-factory', function(nmf) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "case-sensitive-paths-webpack-plugin",
"version": "1.1.3",
"version": "1.1.4",
"description": "Enforces module path case sensitivity in Webpack",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d02babf

Please sign in to comment.