#!/usr/bin/env node var log = require('npmlog') var fs = require('fs') var runSpaceSync = require('../') var usageParams try { usageParams = require('../dist/usageParams') } catch (err) { if (err.code === 'MODULE_NOT_FOUND') { usageParams = require('../lib/usageParams') } else { console.log(err) process.exit(1) } } // welcome the user and let them know what's gonna happen log.info('Contentful Space Sync:\n' + 'Let\'s sync some content across spaces!') var hasTokenFile try { hasTokenFile = !!fs.statSync(usageParams.syncTokenFile) } catch (e) { hasTokenFile = false } if (!hasTokenFile) { log.info('No previous sync token found.\n' + 'Synchronizing fresh content from ' + usageParams.opts.sourceSpace + ' to ' + usageParams.opts.destinationSpace) } else { log.info('Synchronizing content from ' + usageParams.opts.sourceSpace + ' to ' + usageParams.opts.destinationSpace + 'with existing token from ' + usageParams.syncTokenFile) } // Allow the user some time to cancel their action after the previous warning setTimeout(function () { runSpaceSync(usageParams) .catch(function (err) { log.error('Failed with\n', err) process.exit(1) }) }, 3000)