diff --git a/Gulpfile.js b/Gulpfile.js index 78adc0b0..049eea7c 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -2,11 +2,13 @@ const babel = require('rollup-plugin-babel'); const connect = require('connect'); const eslint = require('gulp-eslint'); +const fs = require('fs'); const gulp = require('gulp'); const header = require('gulp-header'); const http = require('http'); const minify = require('uglify-js').minify; const mochaPhantomJS = require('gulp-mocha-phantomjs'); +const path = require('path'); const rollup = require('rollup-stream'); const serveStatic = require('serve-static'); const source = require('vinyl-source-stream'); @@ -20,11 +22,11 @@ const banner = ['/**', ' * <%= pkg.name %> - <%= pkg.description %>', ' * @version v<%= pkg.version %>', ' * @link <%= pkg.homepage %>', - ' * @license <%= pkg.license %>', - ' */', + ' * @author <%= pkg.author %>', + ' * @license <%= pkg.license %> */', ''].join('\n'); -gulp.task('build', () => +gulp.task('do-build', () => rollup({ entry: './src/postmate.js', format: 'umd', @@ -41,6 +43,15 @@ gulp.task('build', () => .pipe(gulp.dest('./build')) ); +gulp.task('update-readme', () => { + const readme = path.join(__dirname, 'README.md'); + const data = fs.readFileSync(readme, 'utf-8'); + const distSize = fs.statSync(path.join(__dirname, 'build', 'postmate.min.js')).size; + const updated = data.replace(/(.*?)<\/span>/, + `\`${(distSize / 1024).toFixed(1)}kb\``); + fs.writeFileSync(readme, updated); +}); + gulp.task('lint', () => gulp.src(['**/*.js', '!node_modules/**', '!build/**']) .pipe(eslint()) @@ -83,4 +94,5 @@ gulp.task('test', ['parent-test-server', 'child-test-server', 'do-test'], () => }); gulp.task('watch', () => gulp.watch('./src/postmate.js', ['build'])); +gulp.task('build', ['do-build', 'update-readme']); gulp.task('build-watch', ['build', 'watch']); diff --git a/README.md b/README.md index 9281a5a0..efa92e46 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ You can download the compiled javascript directly [here](/build/postmate.min.js) * Child exposes a `model`, an object literal whose values consist of serializable values, functions and promises, that the parent can retrieve. * Child can emit events that the parent can listen to. * *Zero* dependencies. Provide your own polyfill or abstraction for the `Promise` API if needed -* Lightweight, weighing in at ~ `3kb` +* Lightweight, weighing in at ~ `4.6kb` ## Installing Postmate can be installed via NPM or Bower. diff --git a/build/postmate.min.js b/build/postmate.min.js index 6dc1c8eb..fc20d6db 100644 --- a/build/postmate.min.js +++ b/build/postmate.min.js @@ -1,7 +1,7 @@ /** * postmate - A powerful, simple, promise-based postMessage library - * @version v0.3.0 + * @version v1.0.0 * @link https://github.com/dollarshaveclub/postmate - * @license MIT - */ + * @author Jacob Kelley + * @license MIT */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Postmate=t()}(this,function(){"use strict";function e(){var e;l.debug&&(e=console).log.apply(e,arguments)}function t(e){var t=document.createElement("a");return t.href=e,t.origin}function n(e,t){return e.origin===t&&("object"===a(e.data)&&("postmate"in e.data&&e.data.type===o))}function i(e,t){var n="function"==typeof e[t]?e[t]():e[t];return Promise.resolve(n)}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},s=function(){function e(e,t){for(var n=0;n