Skip to content

Commit

Permalink
Misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jakiestfu committed Aug 27, 2016
1 parent 270052c commit ece0f80
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
18 changes: 15 additions & 3 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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',
Expand All @@ -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 class="size">(.*?)<\/span>/,
`<span class="size">\`${(distSize / 1024).toFixed(1)}kb\`</span>`);
fs.writeFileSync(readme, updated);
});

gulp.task('lint', () =>
gulp.src(['**/*.js', '!node_modules/**', '!build/**'])
.pipe(eslint())
Expand Down Expand Up @@ -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']);
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~ <span class="size">`4.6kb`</span>

## Installing
Postmate can be installed via NPM or Bower.
Expand Down
6 changes: 3 additions & 3 deletions build/postmate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postmate",
"version": "0.3.0",
"version": "1.0.0",
"description": "A powerful, simple, promise-based postMessage library",
"main": "src/postmate.js",
"devDependencies": {
Expand All @@ -25,7 +25,7 @@
},
"scripts": {
"test": "gulp test",
"build": "gulp build",
"build": "gulp build && gulp update-readme",
"build-watch": "gulp build-watch",
"lint": "gulp lint",
"postpublish": "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push origin --tags"
Expand Down

0 comments on commit ece0f80

Please sign in to comment.