From fe67975036735517ded9c1e0b303cc48ad3cccfb Mon Sep 17 00:00:00 2001 From: DaQuirm Date: Thu, 16 Jan 2014 22:26:12 +0300 Subject: [PATCH 1/2] Update grunt-contrib-uglify and remove tabs from package.json --- package.json | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index eceb72ed..ae105a8d 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,27 @@ { - "name": "VerbalExpressions", - "description": "JavaScript Regular expressions made easy", - "version": "0.1.2", - "keywords": [ "regular expressions", "regex" ], - "homepage": "https://github.com/VerbalExpressions/JSVerbalExpressions", - "devDependencies": { + "name": "VerbalExpressions", + "description": "JavaScript Regular expressions made easy", + "version": "0.1.2", + "keywords": [ "regular expressions", "regex" ], + "homepage": "https://github.com/VerbalExpressions/JSVerbalExpressions", + "devDependencies": { "grunt": "~0.4.2", - "grunt-contrib-qunit": "~0.2.2", - "grunt-contrib-uglify": "~0.2.2" - }, - "repository": { - "type": "git", - "url": "git://github.com/VerbalExpressions/JSVerbalExpressions.git" - }, - "bugs": { - "url": "https://github.com/VerbalExpressions/JSVerbalExpressions/issues" - }, - "main": "VerbalExpressions.js", - "license": { - "type": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "engines": { - "node": ">= 0.8.0" - } + "grunt-contrib-qunit": "~0.2.2", + "grunt-contrib-uglify": "~0.3.0" + }, + "repository": { + "type": "git", + "url": "git://github.com/VerbalExpressions/JSVerbalExpressions.git" + }, + "bugs": { + "url": "https://github.com/VerbalExpressions/JSVerbalExpressions/issues" + }, + "main": "VerbalExpressions.js", + "license": { + "type": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "engines": { + "node": ">= 0.8.0" + } } From 678dbb6a29336395e73364fc65c0df8cd5bb984b Mon Sep 17 00:00:00 2001 From: DaQuirm Date: Thu, 16 Jan 2014 22:27:22 +0300 Subject: [PATCH 2/2] Add source map generation and related tasks --- Gruntfile.js | 31 ++++++++++++++++++++++++----- README.md | 8 +++++--- package.json | 55 ++++++++++++++++++++++++++++------------------------ 3 files changed, 61 insertions(+), 33 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 395cdde1..e8ded070 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,11 +1,18 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - + qunit: { files: ['test/index.html'] }, + copy: { + build: { + src: '<%= pkg.name %>.js', + dest: 'dist/<%= pkg.name %>.js' + } + }, + uglify: { options: { banner: '/*!\n' + @@ -18,17 +25,31 @@ module.exports = function(grunt) { '*\n' + '* Date: <%= grunt.template.today("yyyy-mm-dd") %>\n' + '*\n' + - '*/\n' + '*/\n', + sourceMap: true }, dist: { files: {'dist/<%= pkg.name %>.min.js' : ['<%= pkg.name %>.js']} } + }, + + sourcemap_localize: { + options: { + localize_to : '..' + }, + build: { + files: { + src: ['dist/*.min.map'] + } + } } }); - grunt.loadNpmTasks("grunt-contrib-qunit"); - grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks("grunt-contrib-copy"); + grunt.loadNpmTasks("grunt-contrib-qunit"); + grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks('grunt-sourcemap-localize'); grunt.registerTask('test', 'qunit'); grunt.registerTask('default', ['qunit']); - grunt.registerTask('build', ['qunit', 'uglify']); + grunt.registerTask('build', ['qunit', 'copy', 'uglify', 'sourcemap_localize']); }; diff --git a/README.md b/README.md index 84df9060..12312b3f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ VerbalExpressions v0.1.2 VerbalExpressions is a JavaScript library that helps to construct difficult regular expressions. ## Other Implementations -You can see an up to date list of all ports on [VerbalExpressions.github.io](http://VerbalExpressions.github.io). +You can see an up to date list of all ports on [VerbalExpressions.github.io](http://VerbalExpressions.github.io). - [Ruby](https://github.com/ryan-endacott/verbal_expressions) - [C#](https://github.com/VerbalExpressions/CSharpVerbalExpressions) - [Python](https://github.com/VerbalExpressions/PythonVerbalExpressions) @@ -35,7 +35,7 @@ var VerEx = require("verbal-expressions"); ## Running tests - $ grunt + $ grunt (or) $ grunt test @@ -45,6 +45,8 @@ This will generate a minified version of VerbalExpressions.js (aptly named Verba $ grunt build +A source map will also be created in the same folder, so you can use the original unminified source file (copied to _dist_ as well) for debugging purposes. + ## Examples Here's a couple of simple examples to give an idea of how VerbalExpressions works: @@ -69,7 +71,7 @@ var testMe = "https://www.google.com"; if( tester.test( testMe ) ) alert( "We have a correct URL "); // This output will fire else alert( "The URL is incorrect" ); -console.log( tester ); // Ouputs the actual expression used: /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/ +console.log( tester ); // Ouputs the actual expression used: /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/ ``` ### Replacing strings diff --git a/package.json b/package.json index ae105a8d..2d22f3ea 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,32 @@ { - "name": "VerbalExpressions", - "description": "JavaScript Regular expressions made easy", - "version": "0.1.2", - "keywords": [ "regular expressions", "regex" ], - "homepage": "https://github.com/VerbalExpressions/JSVerbalExpressions", - "devDependencies": { - "grunt": "~0.4.2", - "grunt-contrib-qunit": "~0.2.2", - "grunt-contrib-uglify": "~0.3.0" - }, - "repository": { - "type": "git", - "url": "git://github.com/VerbalExpressions/JSVerbalExpressions.git" - }, - "bugs": { - "url": "https://github.com/VerbalExpressions/JSVerbalExpressions/issues" - }, - "main": "VerbalExpressions.js", - "license": { - "type": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "engines": { - "node": ">= 0.8.0" - } + "name": "VerbalExpressions", + "description": "JavaScript Regular expressions made easy", + "version": "0.1.2", + "keywords": [ + "regular expressions", + "regex" + ], + "homepage": "https://github.com/VerbalExpressions/JSVerbalExpressions", + "devDependencies": { + "grunt": "~0.4.2", + "grunt-contrib-qunit": "~0.2.2", + "grunt-contrib-uglify": "~0.3.0", + "grunt-sourcemap-localize": "~0.1.0", + "grunt-contrib-copy": "~0.5.0" + }, + "repository": { + "type": "git", + "url": "git://github.com/VerbalExpressions/JSVerbalExpressions.git" + }, + "bugs": { + "url": "https://github.com/VerbalExpressions/JSVerbalExpressions/issues" + }, + "main": "VerbalExpressions.js", + "license": { + "type": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "engines": { + "node": ">= 0.8.0" + } }