Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
do not sync versions that already exist on the destination
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzoller committed Jul 9, 2015
1 parent 5dc7a03 commit 59bab83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dependencies": {
"fibers": "^1.0.5",
"fibrous": "^0.4.0",
"lodash": "^3.10.0",
"minimist": "^1.1.1",
"npm-registry-client": "^6.4.0"
},
Expand Down
17 changes: 15 additions & 2 deletions src/cli.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ path = require 'path'
fs = require 'fs'
fibrous = require 'fibrous'
RegClient = require 'npm-registry-client'
_ = require 'lodash'

module.exports = fibrous (argv) ->

Expand All @@ -24,9 +25,21 @@ module.exports = fibrous (argv) ->
npm = new RegClient()

for moduleName in argv._
moduleData = npm.sync.get "#{from.url}/#{moduleName}", auth: from.auth, timeout: 3000
fromVersions = npm.sync.get("#{from.url}/#{moduleName}", auth: from.auth, timeout: 3000).versions
try
toVersions = npm.sync.get("#{to.url}/#{moduleName}", auth: to.auth, timeout: 3000).versions
catch e
throw e unless e.code is 'E404'
toVersions = {}

versionsToSync = _.difference Object.keys(fromVersions), Object.keys(toVersions)

for semver, oldMetadata of fromVersions

unless semver in versionsToSync
console.log "#{moduleName}@#{semver} already exists on destination"
continue

for semver, oldMetadata of moduleData.versions
{dist} = oldMetadata

# clone the metadata skipping private properties and 'dist'
Expand Down

0 comments on commit 59bab83

Please sign in to comment.