Add a package npm task and check in a generated file

This commit is contained in:
Matthew Beale 2012-01-13 11:01:30 -05:00
parent 04568d271e
commit 71c06c7da4
2 changed files with 18 additions and 6 deletions

View file

@ -77,6 +77,7 @@ task 'build', 'build Chosen from source', build = (cb) ->
write_chosen_javascript javascript.replace(/\.js$/,'.min.js'), ( write_chosen_javascript javascript.replace(/\.js$/,'.min.js'), (
uglify.gen_code uglify.ast_squeeze uglify.ast_mangle parser.parse code uglify.gen_code uglify.ast_squeeze uglify.ast_mangle parser.parse code
) )
package_npm () ->
cb() if typeof cb is 'function' cb() if typeof cb is 'function'
catch e catch e
print_error e, file_name, file_contents print_error e, file_name, file_contents
@ -94,6 +95,17 @@ task 'watch', 'watch coffee/ for changes and build Chosen', ->
invoke 'build' invoke 'build'
)(file) )(file)
task 'package_npm', 'generate the package.json file for npm', package_npm = (cb) ->
try
package_file = 'package.json'
package = JSON.parse("#{fs.readFileSync package_file}")
package['version'] = version()
fs.writeFileSync package_file, JSON.stringify(package, null, 2)
console.log "Wrote #{package_file}"
cb() if typeof cb is 'function'
catch e
print_error e, package_file
run = (cmd, args, cb, err_cb) -> run = (cmd, args, cb, err_cb) ->
exec "#{cmd} #{args.join(' ')}", (err, stdout, stderr) -> exec "#{cmd} #{args.join(' ')}", (err, stdout, stderr) ->
if err isnt null if err isnt null

View file

@ -1,7 +1,7 @@
{ {
"author": "harvest", "author": "harvest",
"name": "chosen", "name": "chosen",
"version": "0.9.5-35-g880a30d", "version": "0.9.6",
"description": "Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly. It is currently available in both jQuery and Prototype flavors.", "description": "Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly. It is currently available in both jQuery and Prototype flavors.",
"repository": { "repository": {
"type": "git", "type": "git",
@ -10,9 +10,9 @@
"engines": { "engines": {
"node": ">=0.4.0" "node": ">=0.4.0"
}, },
"dependencies": { "dependencies": {},
"devDependencies": {
"coffee-script": ">= 1.2.0", "coffee-script": ">= 1.2.0",
"uglify-js": ">= 1.2.3" "uglify-js": ">= 1.2.3"
}, }
"devDependencies": {}
} }