-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify files have BOM during publish task
This verification is designed to simulate part of the Windows App Certification Kit test. Protects us from regressing winjs/winjs#1315 in the future.
- Loading branch information
Adam Comella
committed
Aug 10, 2015
1 parent
3b0fb38
commit a38b403
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. | ||
(function () { | ||
"use strict"; | ||
|
||
module.exports = function (grunt) { | ||
|
||
// Verifies that files begin with a UTF8 BOM. Files without one will not be able to pass the | ||
// Windows App Certification Kit test. | ||
|
||
grunt.registerMultiTask("check-bom", function () { | ||
function checkBom(filePath) { | ||
if (grunt.file.exists(filePath)) { | ||
var content = grunt.file.read(filePath, { encoding: null }); | ||
if (content.length < 3 || content[0] !== 0xef || content[1] !== 0xbb || content[2] !== 0xbf) { | ||
grunt.fail.fatal("check-bom File is missing BOM: " + filePath); | ||
} | ||
} else { | ||
grunt.log.warn("check-bom No such file: " + filePath); | ||
} | ||
} | ||
|
||
this.filesSrc.forEach(checkBom); | ||
}); | ||
|
||
}; | ||
})(); |