Skip to content

Commit

Permalink
fix(product-type-generator): Fix outdated jszip code
Browse files Browse the repository at this point in the history
  • Loading branch information
junajan committed May 31, 2017
1 parent 3c903f6 commit f0b340e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/coffee/run.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,19 @@ writeFileAsync = (productTypeDefinition, target, prefix = 'product-type') ->

zipFiles = (path, filename) ->
zip = new JSZip()
zip.folder('product-type-json')
folder = zip.folder('product-type-json')
fs.readdirAsync(path)
.then (allFiles) ->
jsonFiles = _.filter allFiles, (file) -> file.match(/\.json/)
Promise.map jsonFiles, (file) ->
zip.file("product-type-json/#{file}", fs.readFileSync("#{path}/#{file}", 'utf8'))
folder.file("product-type-json/#{file}", fs.readFileSync("#{path}/#{file}", 'utf8'))
.then ->
buffer = zip.generate type: 'nodebuffer'
fs.writeFileAsync "#{path}/#{filename}.zip", buffer, 'utf8'
new Promise (resolve, reject) ->
folder
.generateNodeStream { type: 'nodebuffer', streamFiles:true }
.pipe fs.createWriteStream("#{path}/#{filename}.zip")
.on 'error', (err) -> reject(err)
.on 'finish', resolve

saveProductTypes = (result) ->
console.log 'About to write files...'
Expand Down

0 comments on commit f0b340e

Please sign in to comment.