Skip to content

Commit

Permalink
Merge pull request madrobby#1201 from madrobby/npm
Browse files Browse the repository at this point in the history
Add `make publish` target for npm
  • Loading branch information
mislav authored Jul 13, 2016
2 parents 4dc5e2f + c151149 commit 0818ce9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*
!README.md
!MIT-LICENSE
!dist/zepto.js
!dist/zepto.min.js
!src/*.js
src/amd_layout.js
23 changes: 20 additions & 3 deletions make
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'shelljs/make'
fs = require 'fs'

version = '1.1.6'
zepto_js = 'dist/zepto.js'
zepto_min = 'dist/zepto.min.js'
zepto_gz = 'dist/zepto.min.gz'
Expand Down Expand Up @@ -63,6 +62,18 @@ target.compress = ->
factor = fsize(zepto_js) / fsize(zepto_gz)
echo "compression factor: #{format_number(factor)}"

target.publish = ->
tag = 'v' + package_version()
if git_version() == tag
rm '-r', zepto_js
env['MODULES'] = env['NOAMD'] = ''
target.dist()
res = exec 'npm publish'
exit res.code
else
console.error 'error: latest commit should be tagged with ' + tag
exit 1

## HELPERS ##

stale = (file, source) ->
Expand All @@ -83,9 +94,15 @@ format_number = (size, precision = 1) ->
report_size = (file) ->
echo "#{file}: #{format_number(fsize(file) / 1024)} KiB"

describe_version = ->
package_version = ->
JSON.parse(cat('package.json')).version

git_version = ->
desc = exec "git --git-dir='#{root + '.git'}' describe --tags HEAD", silent: true
if desc.code is 0 then desc.output.replace(/\s+$/, '') else version
desc.output.replace(/\s+$/, '') if desc.code is 0

describe_version = ->
git_version() || package_version()

minify = (source_code) ->
uglify = require('uglify-js')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "zepto"
, "version": "1.1.6"
, "main": "dist/zepto.js"
, "homepage": "http://zeptojs.com"
, "scripts": {
"test": "coffee make test"
Expand Down

0 comments on commit 0818ce9

Please sign in to comment.