Skip to content

Commit

Permalink
fix(transformation): Fix the problem where the file field is empty af…
Browse files Browse the repository at this point in the history
…ter asset transformation

the sync tool was not able to process assets correctly due to a wrong transformation done the asset

closes #68
  • Loading branch information
Khaledgarbaya committed Jul 4, 2016
1 parent 50b8429 commit c6e8408
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/transform/transformers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { omit, pick } from 'lodash/object'
import { find, reduce } from 'lodash/collection'

/**
* Default transformer methods for each kind of entity.
*
Expand All @@ -17,17 +16,19 @@ export function entries (entry) {
}

export function assets (asset) {
asset.fields = pick(asset.fields, 'title', 'description')
asset.fields.file = reduce(
const transformedAsset = omit(asset, 'sys')
transformedAsset.sys = pick(asset.sys, 'id')
transformedAsset.fields = pick(asset.fields, 'title', 'description')
transformedAsset.fields.file = reduce(
asset.fields.file,
(newFile, file, locale) => {
newFile[locale] = omit(file, 'url', 'details')
newFile[locale].upload = 'https:' + file.url
return newFile
},
{}
)
return asset
(newFile, file, locale) => {
newFile[locale] = omit(file, 'url', 'details')
newFile[locale].upload = 'http:' + file.url
return newFile
},
{}
)
return transformedAsset
}

export function locales (locale, destinationLocales) {
Expand Down

0 comments on commit c6e8408

Please sign in to comment.