diff --git a/.travis.yml b/.travis.yml index a5c1b7d..22bf871 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "0.8" + - "0.12.2" before_script: - npm install -g grunt-cli - npm install grunt diff --git a/README.md b/README.md index 02f07a5..87e5dc7 100644 --- a/README.md +++ b/README.md @@ -228,4 +228,4 @@ Released under the MIT license *** -_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 10, 2014._ \ No newline at end of file +_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 10, 2014._ diff --git a/package.json b/package.json index 7add76f..15d9c7c 100644 --- a/package.json +++ b/package.json @@ -22,25 +22,25 @@ ], "main": "Gruntfile.js", "engines": { - "node": ">= 0.8.0" + "node": ">= 0.12.2" }, "scripts": { "test": "grunt test" }, "dependencies": { - "async": "~0.9.0", - "globby": "^0.1.1", - "js-beautify": "~1.5.4", - "lodash": "~2.4.1", - "underscore.string": "~2.3.3" + "async": "~2.0.0-rc.3", + "globby": "~4.0.0", + "js-beautify": "~1.6.2", + "lodash": "~4.11.1", + "underscore.string": "~3.3.4" }, "devDependencies": { - "assemble": "~0.4.27", - "grunt": "~0.4.2", - "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-jshint": "~0.7.2", + "assemble": "^0.10.0", + "grunt": "~1.0.1", + "grunt-contrib-clean": "~1.0.0", + "grunt-contrib-jshint": "~1.0.0", "mocha": "*", - "verb": ">= 0.2.6" + "verb": "~0.8.10" }, "keywords": [ "beautifier", @@ -58,4 +58,4 @@ "prettifier", "prettify" ] -} \ No newline at end of file +} diff --git a/tasks/prettify.js b/tasks/prettify.js index 9a06b84..9fc8fba 100644 --- a/tasks/prettify.js +++ b/tasks/prettify.js @@ -12,7 +12,7 @@ */ var fs = require('fs'); -var path = require('path'); +// var path = require('path'); var glob = require('globby'); var prettify = require('js-beautify').html; var _str = require('underscore.string'); @@ -20,6 +20,57 @@ var _ = require('lodash'); module.exports = function (grunt) { + + function normalize(str) { + return str.replace(/\r/g, ''); + } + + function stripBOM(str) { + if (str.charCodeAt(0) === 0xFEFF) { + return str.slice(1); + } + return str; + } + + function read(fp) { + var str = fs.readFileSync(fp, 'utf8'); + str = normalize(str); + return stripBOM(str); + } + + // Normalize and condense all newlines + function condense(str) { + return str.replace(/(\r\n|\n\r|\n|\r){2,}/g, '\n'); + } + + // fix multiline, Bootstrap-style comments + function padcomments(str, num) { + var nl = _str.repeat('\n', (num || 1)); + return str.replace(/(\s*)(