diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..b18a440 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,37 @@ +var gulp = require('gulp'); +var browserify = require('browserify'); +var uglify = require('gulp-uglify'); +var source = require('vinyl-source-stream'); +var buffer = require('vinyl-buffer'); +var header = require('gulp-header'); +var insert = require('gulp-insert'); +var pkg = require('./package.json'); + +gulp.task('build', function() { + return browserify(pkg.main).bundle() + .pipe(source(pkg.name + '.min.js')) + .pipe(buffer()) + .pipe(insert.wrap( + ';!function() {' + + ' var name = \'RandExp\';' + + ' var obj = (function() { return ', + '})()(1);' + + ' if (typeof define === \'function\' && ' + + ' typeof define.amd === \'object\') {' + + ' define(name, function() { return obj; });' + + ' } else if (typeof window !== \'undefined\') {' + + ' window[name] = obj;' + + ' }' + + '}();')) + .pipe(uglify()) + .pipe(header( + '//\n' + + '// ${pkg.name} v${pkg.version}\n' + + '// ${pkg.description}\n' + + '//\n' + + '// Copyright (C) ${year} by ${pkg.author}\n' + + '// ${pkg.licenses[0].type} License\n' + + '// ${pkg.licenses[0].url} \n' + + '//\n', { pkg: pkg, year: new Date().getFullYear() })) + .pipe(gulp.dest('build')); +}); diff --git a/package.json b/package.json index 31dbfb8..fb0e19e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,13 @@ { "name": "randexp", "description": "Create random strings that match a given regular expression.", - "keywords": ["regex", "regexp", "regular expression", "random", "test"], + "keywords": [ + "regex", + "regexp", + "regular expression", + "random", + "test" + ], "version": "0.4.0", "homepage": "http://fent.github.io/randexp.js/", "repository": { @@ -21,10 +27,19 @@ "ret": "0.1.10" }, "devDependencies": { - "mocha": "x" + "browserify": "^11.1.0", + "gulp": "^3.9.0", + "gulp-header": "^1.7.1", + "gulp-insert": "^0.5.0", + "gulp-uglify": "^1.4.1", + "mocha": "x", + "vinyl-buffer": "^1.0.0", + "vinyl-source-stream": "^1.1.0" }, - "licenses": [ { - "type": "MIT", - "url" : "http://github.com/fent/randexp.js/raw/master/LICENSE" - }] + "licenses": [ + { + "type": "MIT", + "url": "http://github.com/fent/randexp.js/raw/master/LICENSE" + } + ] }