【发布时间】:2014-07-30 02:55:44
【问题描述】:
在我的Gruntfile.coffee,我设置了一个任务:
grunt.registerTask 'couch_upload', 'CouchDB upload', ->
done = @async()
assets = ['combined.min.js', 'screen.min.css']
ddoc = 'http://localhost:5984/mydb/_design/app'
request = require 'request'
fs = require 'fs'
grunt.log.writeln 'Uploading assets...'
upload = (asset) ->
# get the revision of the design document
request.get {json: yes, url: ddoc}, (err, resp, body) ->
rev = body._rev
# stream the file and pipe it, so it has the correct Content-Type
fs.createReadStream('build/' + asset).pipe request.put
auth: user: 'myusername', password: 'mypass'
headers: 'If-Match': rev
url: [ddoc, asset].join '/'
, -> grunt.log.write ' ' + asset
upload asset for asset in assets
done()
但是我在 Grunt 的日志和 Couch 的日志上都看不到任何上传的内容。
你能告诉我我做错了什么吗?
【问题讨论】:
标签: coffeescript gruntjs couchdb