Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
fix(opts): move validation of the opts to later stage (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaledgarbaya committed Nov 29, 2016
1 parent 8485db5 commit a5123cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 8 additions & 2 deletions lib/run-space-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import dumpErrorBuffer from './dump-error-buffer'
import getTransformedDestinationResponse from './get-transformed-destination-response'

export default function runSpaceSync (usageParams) {
const {opts, syncTokenFile, errorLogFile} = usageParams
let {opts, errorLogFile, syncTokenFile} = usageParams
opts.sourceManagementToken = opts.sourceManagementToken || opts.managementToken
opts.destinationManagementToken = opts.destinationManagementToken || opts.managementToken
const tokenDir = opts.syncTokenDir || process.cwd()
errorLogFile = errorLogFile || tokenDir + '/contentful-space-sync-' + Date.now() + '.log'
syncTokenFile = syncTokenFile || tokenDir + '/contentful-space-sync-token-' + opts.sourceSpace + '-to-' + opts.destinationSpace

if (opts.proxyHost && opts.proxyPort) {
opts.proxy = {host: opts.proxyHost, port: opts.proxyPort}
}
Expand Down Expand Up @@ -72,7 +78,7 @@ export default function runSpaceSync (usageParams) {
const nextSyncToken = responses.source.nextSyncToken
if (!opts.contentModelOnly && nextSyncToken) {
fs.writeFileSync(syncTokenFile, nextSyncToken)
log.info('Successfully sychronized the content and saved the sync token to:\n ', syncTokenFile)
log.info('Successfully sychronized the content and saved the sync token to:\n ', opts.syncTokenFile)
} else {
log.info('Successfully sychronized the content model')
}
Expand Down
9 changes: 1 addition & 8 deletions lib/usageParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ var opts = yargs
})
.argv

opts.sourceManagementToken = opts.sourceManagementToken || opts.managementToken
opts.destinationManagementToken = opts.destinationManagementToken || opts.managementToken

var tokenDir = opts.syncTokenDir || process.cwd()

module.exports = {
opts: opts,
errorLogFile: tokenDir + '/contentful-space-sync-' + Date.now() + '.log',
syncTokenFile: tokenDir + '/contentful-space-sync-token-' + opts.sourceSpace + '-to-' + opts.destinationSpace
opts: opts
}

0 comments on commit a5123cf

Please sign in to comment.