From af88a110ed0333cb3ef443a941c7b6c708ab3d42 Mon Sep 17 00:00:00 2001 From: Jeff Wainwright Date: Tue, 1 Nov 2016 20:58:11 -0700 Subject: [PATCH] adds version & min file --- dist/shave.min.js | 7 +++++++ gulpfile.js | 22 +++++++++++++++++++++- package.json | 23 +++++++++++++---------- tests/index.html | 2 +- 4 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 dist/shave.min.js diff --git a/dist/shave.min.js b/dist/shave.min.js new file mode 100644 index 00000000..c9ce49b7 --- /dev/null +++ b/dist/shave.min.js @@ -0,0 +1,7 @@ +/** + * shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height + * @version v0.1.7 + * @link https://github.com/dollarshaveclub/shave#readme + * @author Jeff Wainwright (jeffr.in) + * @license ISC */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.shave=t()}(this,function(){"use strict";function e(e,t,n){if(!t)throw Error("maxHeight is required");var s="string"==typeof e?document.querySelectorAll(e):e;"length"in s||(s=[s]);for(var r={character:"…",classname:"js-shave",spaces:!0},o=n&&n.character||r.character,a=n&&n.classname||r.classname,i=(!n||n.spaces!==!1)&&r.spaces,c=''+o+"",f=0;f>1,l.textContent=i?u.slice(0,j).join(" "):u.slice(0,j),l.insertAdjacentHTML("beforeend",c),l.offsetHeight>t?p=i?j-1:j-2:v=j;l.textContent=i?u.slice(0,p).join(" "):u.slice(0,p),l.insertAdjacentHTML("beforeend",c);var y=i?u.slice(p+1).join(" "):u.slice(p);l.insertAdjacentHTML("beforeend",'")}}}}var t=window.$||window.jQuery||window.Zepto;return t&&t.fn.extend({shave:function(t,n){return e(this,t,n)}}),e}); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 3a30769b..cd101c1a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,8 +1,28 @@ const gulp = require('gulp'); +const head = require('gulp-header'); +const uglify = require('gulp-uglify'); +const rename = require('gulp-rename'); const qunit = require('node-qunit-phantomjs'); +const pkg = require('./package.json'); +const banner = ['/**', + ' * <%= pkg.name %> - <%= pkg.description %>', + ' * @version v<%= pkg.version %>', + ' * @link <%= pkg.homepage %>', + ' * @author <%= pkg.author %>', + ' * @license <%= pkg.license %> */', +''].join('\n'); + gulp.task('test', function() { qunit('tests/index.html'); }); -gulp.task('default', ['test']); +gulp.task('minify', function() { + gulp.src('dist/shave.js') + .pipe(uglify()) + .pipe(head(banner, { pkg })) + .pipe(rename({ suffix: '.min' })) + .pipe(gulp.dest('dist/')); +}); + +gulp.task('default', ['minify', 'test']); diff --git a/package.json b/package.json index 4608f8d5..66959e3c 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "shave", - "version": "0.1.7", + "version": "0.1.8", "description": "Shave is a javascript plugin that truncates multi-line text within a html element based on set max height", "main": "dist/shave.js", - "files": [ + "files": [ "dist" ], "scripts": { "test": "gulp test", - "postpublish": "git tag $npm_package_version && git push origin --tags" + "postpublish": "git tag $npm_package_version && git push origin --tags" }, "repository": { "type": "git", @@ -18,17 +18,17 @@ "ellipsis", "truncate", "truncation", - "truncated", - "semantic", - "js", - "content", + "truncated", + "semantic", + "js", + "content", "shorten", "javascript", "text", - "shave", - "trim" + "shave", + "trim" ], - "author": "Jeff Wainwright (jeffr.in)", + "author": "Jeff Wainwright (jeffry.in)", "license": "ISC", "bugs": { "url": "https://github.com/dollarshaveclub/shave/issues" @@ -43,6 +43,9 @@ "eslint": "^3.4.0", "eslint-config-airbnb": "6.1.0", "gulp": "^3.9.1", + "gulp-header": "^1.8.8", + "gulp-rename": "^1.2.2", + "gulp-uglify": "^2.0.0", "node-qunit-phantomjs": "^1.4.0", "qunit": "^0.9.1", "rollup": "^0.34.13", diff --git a/tests/index.html b/tests/index.html index 46542e6f..b5c00063 100644 --- a/tests/index.html +++ b/tests/index.html @@ -58,5 +58,5 @@

- +