diff --git a/.travis.yml b/.travis.yml index 3500c24..203e5df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,13 @@ language: node_js node_js: + - "5" + - "4" - "0.12" - "0.11" - "0.10" - "iojs" +before_install: + - npm install -g npm install: - npm install script: "npm run-script ci" diff --git a/Gruntfile.js b/Gruntfile.js index 9f69dfb..b64b9ac 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,13 +7,13 @@ module.exports = function(grunt) { grunt.initConfig({ clean: { coverage: { - src: ['coverage'] + src: 'coverage' }, test: { - src: ['test/tmp'] + src: 'test/tmp' }, benchmark: { - src: ['benchmark/result.csv'] + src: 'benchmark/result.csv' } }, copy: { @@ -35,28 +35,22 @@ module.exports = function(grunt) { reporter: 'spec' }, src: ['test/**/*.spec.js'] + } + }, + mocha_istanbul: { + options: { + mask: '*.spec.js', + root: './lib', + check: { + lines: 95, + statements: 95 + } }, - 'html-cov': { - options: { - reporter: 'html-cov', - quiet: true, - captureFile: 'coverage/coverage.html' - }, - src: ['coverage/test/**/*.spec.js'] - }, - 'mocha-lcov-reporter': { - options: { - reporter: 'mocha-lcov-reporter', - quiet: true, - captureFile: 'coverage/lcov.info' - }, - src: ['coverage/test/**/*.spec.js'] - }, - 'travis-cov': { + coverage: { + src: 'test', options: { - reporter: 'travis-cov' - }, - src: ['coverage/test/**/*.spec.js'] + reportFormats: ['lcov'] // html + lcov + } } }, coveralls: { @@ -100,9 +94,7 @@ module.exports = function(grunt) { } }); - grunt.registerTask('prepare-cov', ['clean:coverage', 'blanket', 'copy']); - grunt.registerTask('coverage', - ['prepare-cov', 'mochaTest:html-cov', 'mochaTest:mocha-lcov-reporter', 'mochaTest:travis-cov']); + grunt.registerTask('coverage', ['clean:coverage', 'mocha_istanbul:coverage']); grunt.registerTask('test', ['jshint', 'mochaTest:preprocess']); grunt.registerTask('dev', ['deps-ok', 'watch']); grunt.registerTask('default', ['test', 'coverage']); diff --git a/README.md b/README.md index c2fd913..3f669e8 100644 --- a/README.md +++ b/README.md @@ -351,35 +351,39 @@ In lieu of a formal styleguide, take care to maintain the existing coding style. changed functionality. Lint and test your code using jshint ## Release History - - 3.1.x Added `.jsx` file extension as alias for `js` (via @BendingBender, #79) + - 3.1.x + - Added `.jsx` file extension as an alias for `js` (@BendingBender, #79) + - Added `.tsx` file extension as an alias for `js` (@rosendi, #100) + - Bumped XRegExp to v3 + - 3.0.1/2 Fixes for backward compatibility and regex cleanups (thanks to @anseki for suggestions, #77) - 3.0.0 Breaking changes: - If a file requested by `@include` or `@extend` can not be found, `preprocess` will now throw by default - with a possibility to opt in to the legacy behavior via the `fileNotFoundSilentFail` option (via @BendingBender, #35). - - Fixed multiple issues with newlines (via @BendingBender, #8), this may result in output that differs from earlier + with a possibility to opt in to the legacy behavior via the `fileNotFoundSilentFail` option (@BendingBender, #35). + - Fixed multiple issues with newlines (@BendingBender, #8), this may result in output that differs from earlier versions. - The `srcDir` option was moved to the options object and now defaults to `process.cwd` instead of throwing by - default (via @BendingBender, #68) + default (@BendingBender, #68) New functionality: - - All block directives (ones that have a start and an end token, like `@if`/`@endif`) are now processed recursively (via @Frizi, #61) - - Added hidden by default configuration blocks for `js` (via @mallowigi, #40) and `html` (via @Frizi, #66) + - All block directives (ones that have a start and an end token, like `@if`/`@endif`) are now processed recursively (@Frizi, #61) + - Added hidden by default configuration blocks for `js` (@mallowigi, #40) and `html` (@Frizi, #66) Fixes: - - fixed `@exec` in files included via `@include` and `@extend` (via @BendingBender, #58) - - changed `@extend` and `@exclude` html regex so that directives may appear more than once in one line (via @BendingBender, #36) - - fixed multiple issues with coffescript syntax (via @BendingBender, #39) - - fixed `@if` and `@foreach` to not require trailing whitespace (via @BendingBender, #74) - - - 2.3.1 Fixed @echo and @exec directives to allow `-` and `*` characters, fixed @exec with multiple params (via @BendingBender, #21, #45, #51, #54). - - 2.3.0 Added support for @include-static (via @BendingBender) - - 2.2.0 Added support for @foreach and @extend (via @orionstein) - - 2.1.1 Added support for .styl files via js regex (via @nsonnad) + - fixed `@exec` in files included via `@include` and `@extend` (@BendingBender, #58) + - changed `@extend` and `@exclude` html regex so that directives may appear more than once in one line (@BendingBender, #36) + - fixed multiple issues with coffescript syntax (@BendingBender, #39) + - fixed `@if` and `@foreach` to not require trailing whitespace (@BendingBender, #74) + + - 2.3.1 Fixed @echo and @exec directives to allow `-` and `*` characters, fixed @exec with multiple params (@BendingBender, #21, #45, #51, #54). + - 2.3.0 Added support for @include-static (@BendingBender) + - 2.2.0 Added support for @foreach and @extend (@orionstein) + - 2.1.1 Added support for .styl files via js regex (@nsonnad) - 2.1.0 Added automatic support for numerous formats, merged @exec, hidden by default html tags, added simple directives - 2.0.0 Added ability to echo strings, added conditional comments, removed lodash, merged 17, 13, 15, 16 - - 1.2.0 Added processing for hash-style comments (via @marsch). Added more file aliases. + - 1.2.0 Added processing for hash-style comments (@marsch). Added more file aliases. - 1.1.0 Added deep inclusion, fixed sequential ifs - 1.0.1 Fixed multiple inline echo statements - 1.0.0 Pulled from grunt-preprocess to stand alone diff --git a/appveyor.yml b/appveyor.yml index c7af021..949bde0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,18 +1,24 @@ +init: + - git config --global core.autocrlf false + environment: matrix: - # node.js - nodejs_version: "0.10" - nodejs_version: "0.11" - nodejs_version: "0.12" - # io.js - - nodejs_version: "2" + - nodejs_version: "3" + - nodejs_version: "4" + - nodejs_version: "5" + +platform: + - x86 + - x64 install: # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version # install modules - - npm -g install npm@2 - - set PATH=%APPDATA%\npm;%PATH% + - npm install -g npm - npm install # Post-install test scripts. diff --git a/lib/preprocess.js b/lib/preprocess.js index 1d10bd7..e401d29 100644 --- a/lib/preprocess.js +++ b/lib/preprocess.js @@ -17,7 +17,7 @@ var path = require('path'), fs = require('fs'), os = require('os'), delim = require('./regexrules'), - XRegExp = require('xregexp').XRegExp; + XRegExp = require('xregexp'); function preprocessFile(srcFile, destFile, context, callback, options) { options = getOptionsForFile(srcFile, options); @@ -299,19 +299,18 @@ function replaceRecursive(rv, rule, processor) { }; return matches.reduce(function (builder, match) { - // seems to be a bug in XRegExp, contents of 'value' and 'name' entries are swapped - switch(match.value) { + switch(match.name) { case 'between': - builder += match.name; + builder += match.value; break; case 'left': - matchGroup.left = startRegex.exec(match.name); + matchGroup.left = startRegex.exec(match.value); break; case 'match': - matchGroup.match = match.name; + matchGroup.match = match.value; break; case 'right': - matchGroup.right = endRegex.exec(match.name); + matchGroup.right = endRegex.exec(match.value); builder += processor(matchGroup.left, matchGroup.right, matchGroup.match, matchReplacePass); break; } diff --git a/package.json b/package.json index 57403f9..d7d13f7 100644 --- a/package.json +++ b/package.json @@ -30,26 +30,26 @@ "ci": "grunt ci" }, "dependencies": { - "xregexp": "2.0.0" + "xregexp": "3.1.0" }, "devDependencies": { - "chai": "^3.0.0", - "chai-spies": "^0.6.0", - "grunt": "~0.4.1", + "chai": "^3.5.0", + "chai-spies": "^0.7.0", + "grunt": "^0.4.5", "grunt-benchmark": "^0.3.0", - "grunt-blanket": "0.0.8", "grunt-cli": "^0.1.13", - "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-clean": "^1.0.0", "grunt-contrib-copy": "^0.8.0", - "grunt-contrib-jshint": "^0.11.0", + "grunt-contrib-jshint": "^1.0.0", "grunt-contrib-watch": "^0.6.1", "grunt-coveralls": "^1.0.0", - "grunt-deps-ok": "^0.8.0", + "grunt-deps-ok": "^0.9.0", + "grunt-mocha-istanbul": "^3.0.1", "grunt-mocha-test": "^0.12.7", - "load-grunt-tasks": "^3.2.0", - "mocha": "^2.2.5", - "mocha-lcov-reporter": "0.0.2", - "time-grunt": "^1.2.1", + "istanbul": "^0.4.2", + "load-grunt-tasks": "^3.4.0", + "mocha": "^2.4.5", + "time-grunt": "^1.3.0", "travis-cov": "^0.2.5" }, "keywords": [