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
Windows BOM #806
Comments
See #338. It fixed way more problems than it caused. To date you're the first use case that needs a BOM. :) It seems fairly simple to just add a BOM where it's needed though. Why not just write a task that adds BOMs where needed to pass certification? Unless I'm completely missing something. |
That's what I did, which is on every text file. There's a problem with this because using So using iconv, I just decode the buffer just like in Does this all make sense? |
I know development on windows doesn't mean you are targeting windows, but in this case, I guess I am the first doing that with grunt? |
I don't think Grunt should expose its own dependencies because then users would have to wait for us to publish releases of Grunt to update their libs. npm will sort of do this automatically though. If you install a module with the same version before grunt, it will only install it in one place. But installing a tiny module in two locations isn't a big deal anyways. There are many people using Grunt on Windows, even some of the core contributors are on Windows. I meant you're the first person to ask for the BOM to not be automatically removed. As in most cases programs shouldn't really rely on it being there and don't. So it is a rather useless mark and safe to remove. The Windows Store requiring it is an edge case, imo. But I am +1 for an option to opt out of it being automatically removed. |
I can see there being an option similar to grunt.file.defaultencoding that one can set to preserve BOM. Maybe |
@cowboy This is not urgent, as I do have a working solution right now, but I am +1 for an option like that. |
I've similar problem as @jimisaacs , I'm writing Win8 Store app too, and an option to preserve BOM would be very helpful. |
@jimisaacs @Lucasus I know nothing about BOM, so I need your input. Is the solution as simple as don't strip BOM from files when reading their contents? Because if so, I'll add the if (contents.charCodeAt(0) === 0xFEFF) {
contents = contents.substring(1);
} to: if (!file.preserveBOM && contents.charCodeAt(0) === 0xFEFF) {
contents = contents.substring(1);
} Feel free to test this by temporarily removing those 3 lines from your local Grunt Either way, if you respond today, this stands a very good chance of making it into the upcoming 0.4.2 release! |
@cowboy +1 LGMT, as long as we can pass this option down easy enough. grunt.file.copy(srcpath, destpath, {preserveBOM: true}); I'm thinking not because of this https://github.com/gruntjs/grunt/blob/master/lib/grunt/file.js#L305 grunt.file.copy(srcpath, destpath, {preserveBOM: true, process: function (contents) { return contents; }}); This may be a separate issue, but at the same time, this issue is effected most by the copy task because that's where the BOM is stripped unexpectedly. How about: // does it really matter that `options.process` is passed on?
if (!process) options.encoding = null; |
What I'm saying is that you'd set this at the top of your Gruntfile: grunt.file.preserveBOM = true; And Grunt would preserve BOM in all file read operations, automatically. It would work like the existing grunt.file.defaultencoding method. Will that work for you? |
+1 for it being customizable. |
@cowboy Ah ha, totally read it wrong sorry. |
@nitriques It won't be on by default, you'll have to enable it. But once enabled, it will stay on for all file read / copy operations done through @jimisaacs have you tested it? Do you want to submit a PR? 😀 |
+1 for being customizable (off by default) |
@cowboy Great. would this apply to any other apps that uses grunt (like Yeoman). (I think they use |
@cowboy coming up |
Why was this considered ok? https://github.com/gruntjs/grunt/blob/master/lib/grunt/file.js#L228-L231
When writing a Windows Store app, and ran through WACK, it is required that files contain a BOM, and fails certification otherwise.
If
iconv
was exported I may have found a better short term solution fix, but without it I had to write my own tasks for many things.Also separate topic, how do people feel about the idea of dropping every 3rd party dependency in one namespace such as
grunt.modules
orgrunt.internal
.The text was updated successfully, but these errors were encountered: