From e4d1a3c96d40c468fb9ad9b73cf673ba2eff7aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xmf=E8=96=9B=E6=A2=A6=E9=A3=9E?= Date: Mon, 23 Mar 2015 15:29:43 +0800 Subject: [PATCH] support BOM option --- README.md | 6 ++++++ docs/README.md | 6 ++++++ tasks/replace.js | 3 +++ 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index ba2c1d8..2827f74 100644 --- a/README.md +++ b/README.md @@ -292,6 +292,12 @@ Default: `false` Whether to copy or set the existing file permissions. Set to `true` to copy the existing file permissions. Or set to the mode, i.e.: `0644`, that copied files will be set to. +#### bom +Type: `Boolean` +Default: `false` + +Insert BOM into the front of file. + ### Built-in Replacements Few matching rules are provided by default and can be used anytime (these will be affected by the `options` given): diff --git a/docs/README.md b/docs/README.md index eb5a40d..6da6917 100644 --- a/docs/README.md +++ b/docs/README.md @@ -75,6 +75,12 @@ Default: `false` Whether to copy or set the existing file permissions. Set to `true` to copy the existing file permissions. Or set to the mode, i.e.: `0644`, that copied files will be set to. +#### bom +Type: `Boolean` +Default: `false` + +Insert BOM into the front of file. + ### Built-in Replacements Few matching rules are provided by default and can be used anytime (these will be affected by the `options` given): diff --git a/tasks/replace.js b/tasks/replace.js index f85496b..4f3f0e3 100644 --- a/tasks/replace.js +++ b/tasks/replace.js @@ -130,6 +130,9 @@ module.exports = function (grunt) { grunt.log.writeln('Replace ' + chalk.cyan(source) + ' → ' + chalk.green(target)); } + if (options.bom) { + contents = '\uFEFF' + contents; + } return result; }, noProcess: options.noProcess || options.processContentExclude