     if name?.length > 0 and pack.name isnt name
       message = "Renaming #{pack.name} to #{name}"
       process.stdout.write("#{message}\n")
-      @setPackageName pack, name, =>
+      @setPackageName pack, name, (error) =>
+        if error?
+          return callback(error)
+
         @spawn 'git', ['add', 'package.json'], (code, stderr='', stdout='') =>
           unless code is 0
             addOutput = "#{stdout}\n#{stderr}".trim()

    catch error
      throw new Error("Error parsing package.json file: #{error.message}")

  saveMetadata: (pack) ->
    metadataPath = path.resolve('package.json')
    metadataJson = JSON.stringify(pack, null, 2)
    fs.writeFileSync(metadataPath, "#{metadataJson}\n")

  loadRepository: ->
    currentDirectory = process.cwd()

      callback()

  setPackageName: (pack, name, callback) ->
    pack.name = name
    @saveMetadata(pack, callback)

  # Run the publish command with the given options
  run: (options) ->
