Add unit test to File.addExtension and File.replaceExtension
to test functionality with leading '.' in file string (.file.js)
Fix require statement for both test files (file.js and resolver.js) caused by cacf4e2b6653c43cd425e5cdeda5ba0c20843d6e
This has a failing unit test:
it("then `test/.file.ext1.html` is `test/.file.js`", function() {
var fileString = File.replaceExtension("test/.file.ext1.html", "js");
expect(fileString).to.equal("test/.file.js");
});
File.replaceExtension does not currently work with file paths beginning with ".". This is due to the fact that it uses the first element in the array + the passed extension as the new file name. This breaks when the original file name string starts with . because the array after splitting on . equals ["", "file", "js", "html"].
I do have a work around for this, but I would like to hear your ideas - my workaround consists of doing a check on the first element being an empty string (or perhaps fileName.name.startsWith(".") in ES6) and then using the first two elements of the array as our "first element".
File.replaceExtension
This has a failing unit test:
File.replaceExtension
does not currently work with file paths beginning with ".". This is due to the fact that it uses the first element in the array + the passed extension as the new file name. This breaks when the original file name string starts with.
because the array after splitting on.
equals["", "file", "js", "html"]
.I do have a work around for this, but I would like to hear your ideas - my workaround consists of doing a check on the first element being an empty string (or perhaps
fileName.name.startsWith(".")
in ES6) and then using the first two elements of the array as our "first element".Fixes #4.
/cc @MiguelCastillo