Add a package npm task and check in a generated file

master
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,7 +77,8 @@ task 'build', 'build Chosen from source', build = (cb) ->
write_chosen_javascript javascript.replace(/\.js$/,'.min.js'), (
uglify.gen_code uglify.ast_squeeze uglify.ast_mangle parser.parse code
)
cb() if typeof cb is 'function'
package_npm () ->
cb() if typeof cb is 'function'
catch e
print_error e, file_name, file_contents
@ -94,6 +95,17 @@ task 'watch', 'watch coffee/ for changes and build Chosen', ->
invoke 'build'
)(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) ->
exec "#{cmd} #{args.join(' ')}", (err, stdout, stderr) ->
if err isnt null

View File

@ -1,7 +1,7 @@
{
"author": "harvest",
"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.",
"repository": {
"type": "git",
@ -10,9 +10,9 @@
"engines": {
"node": ">=0.4.0"
},
"dependencies": {
"dependencies": {},
"devDependencies": {
"coffee-script": ">= 1.2.0",
"uglify-js": ">= 1.2.3"
},
"devDependencies": {}
}
}
}