From 90d3e4e87df2df38c9c3e0ca2515799592ddca84 Mon Sep 17 00:00:00 2001 From: Daniel Hengeveld Date: Tue, 29 Jul 2014 12:21:41 -0700 Subject: [PATCH 01/21] Add rename support to the publish command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usage: apm publish —rename --- src/publish.coffee | 79 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 14 deletions(-) diff --git a/src/publish.coffee b/src/publish.coffee index c44f3e085..1c7203c7f 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -24,6 +24,7 @@ class Publish extends Command Usage: apm publish [ | major | minor | patch | build] apm publish --tag + apm publish --rename Publish a new version of the package in the current working directory. @@ -32,12 +33,16 @@ class Publish extends Command it is published to the apm registry. The HEAD branch and the new tag are pushed up to the remote repository automatically using this option. + If a new name is provided via the --rename flag, the package.json file is + updated with the new name and the package's name is updated on Atom.io. + Run `apm featured` to see all the featured packages or `apm view ` to see information about your package after you have published it. """ options.alias('h', 'help').describe('help', 'Print this usage message') options.alias('t', 'tag').string('tag').describe('tag', 'Specify a tag to publish') + options.alias('r', 'rename').string('rename').describe('rename', 'Specify a new name for the package') showHelp: (argv) -> @parseOptions(argv).showHelp() @@ -166,7 +171,7 @@ class Publish extends Command # tag - The string Git tag of the new version. # callback - The callback function to invoke with an error as the first # argument. - createPackageVersion: (packageName, tag, callback) -> + createPackageVersion: (packageName, tag, options, callback) -> Login.getTokenOrLogin (error, token) -> if error? callback(error) @@ -177,6 +182,7 @@ class Publish extends Command json: true body: tag: tag + rename: options.rename headers: authorization: token request.post requestSettings, (error, response, body={}) -> @@ -194,9 +200,12 @@ class Publish extends Command # tag - The Git tag string of the package version to publish. # callback - The callback function to invoke when done with an error as the # first argument. - publishPackage: (pack, tag, callback) -> - process.stdout.write "Publishing #{pack.name}@#{tag} " - @createPackageVersion pack.name, tag, (error) => + publishPackage: (pack, tag, remaining...) -> + options = remaining.shift() if remaining.length >= 2 + callback = remaining.shift() + + process.stdout.write "Publishing #{options.rename || pack.name}@#{tag} " + @createPackageVersion pack.name, tag, options, (error) => if error? @logFailure() callback(error) @@ -222,6 +231,11 @@ class Publish extends Command catch error throw new Error("Error parsing package.json file: #{error.message}") + saveMetadata: (pack) -> + metadataPath = path.resolve('package.json') + out = JSON.stringify(pack, null, 2) + fs.writeFileSync(metadataPath, out) + loadRepository: -> currentDirectory = process.cwd() @@ -240,11 +254,35 @@ class Publish extends Command unless upstreamUrl throw new Error('Package must pushed up to GitHub before publishing: https://help.github.com/articles/create-a-repo') + # Rename package if necessary + renamePackage: (pack, name, callback) -> + if name?.length > 0 + message = "Renaming #{pack.name} to #{name}" + process.stdout.write("#{message}\n") + @setPackageName pack, name, => + @spawn 'git', ['add', 'package.json'], (addCode) => + @spawn 'git', ['commit', '-m', "#{message}"], (code, stderr='', stdout='') => + if code is 0 or addCode is 0 + callback() + else + callback('Failed to commit package.json') + else + # Just fall through if the name is empty + callback() + + setPackageName: (pack, name, callback) -> + if pack.name == name + throw new Error('New package name matches old package name') + + pack.name = name + @saveMetadata(pack) + callback() + # Run the publish command with the given options run: (options) -> {callback} = options options = @parseOptions(options.commandArgs) - {tag} = options.argv + {tag, rename} = options.argv [version] = options.argv._ try @@ -257,22 +295,35 @@ class Publish extends Command catch error return callback(error) - if version?.length > 0 + if version?.length > 0 or rename?.length > 0 + unless version?.length > 0 + version = 'patch' + originalName = pack.name + @registerPackage pack, (error, firstTimePublishing) => + console.log "registering #{pack.name}" return callback(error) if error? - @versionPackage version, (error, tag) => + @renamePackage pack, rename, (error) => return callback(error) if error? - @pushVersion tag, (error) => + @versionPackage version, (error, tag) => return callback(error) if error? - @waitForTagToBeAvailable pack, tag, => + @pushVersion tag, (error) => + return callback(error) if error? + + @waitForTagToBeAvailable pack, tag, => - @publishPackage pack, tag, (error) => - if firstTimePublishing and not error? - @logFirstTimePublishMessage(pack) - callback(error) + if originalName? + # If we're renaming a package, we have to hit the API with the + # current name, not the new one, or it will 404. + rename = pack.name + pack.name = originalName + @publishPackage pack, tag, {rename: rename}, (error) => + if firstTimePublishing and not error? + @logFirstTimePublishMessage(pack) + callback(error) else if tag?.length > 0 @registerPackage pack, (error, firstTimePublishing) => return callback(error) if error? @@ -282,4 +333,4 @@ class Publish extends Command @logFirstTimePublishMessage(pack) callback(error) else - callback('Missing required tag to publish') + callback('Version, tag or rename required to publish') From 0efc009108f694b7609dd3a1c6c32b876d963933 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:34:12 -0700 Subject: [PATCH 02/21] Remove extra registering logging --- src/publish.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 1c7203c7f..3d7236145 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -301,7 +301,6 @@ class Publish extends Command originalName = pack.name @registerPackage pack, (error, firstTimePublishing) => - console.log "registering #{pack.name}" return callback(error) if error? @renamePackage pack, rename, (error) => From 86222431c4967fcee7d4a6723240d0e187088761 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:35:21 -0700 Subject: [PATCH 03/21] Call back with error instead of throwing it --- src/publish.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/publish.coffee b/src/publish.coffee index 3d7236145..31ab034c9 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -271,8 +271,8 @@ class Publish extends Command callback() setPackageName: (pack, name, callback) -> - if pack.name == name - throw new Error('New package name matches old package name') + if pack.name is name + return callback(new Error('New package name matches old package name')) pack.name = name @saveMetadata(pack) From 522ac2980ebc6dcf378a0a61d3c3a3f43ea2020d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:40:54 -0700 Subject: [PATCH 04/21] Tweak missing options message --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 31ab034c9..0b03e79cf 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -332,4 +332,4 @@ class Publish extends Command @logFirstTimePublishMessage(pack) callback(error) else - callback('Version, tag or rename required to publish') + callback('A version, tag, or new package name is required') From 569bffd494127a50216e1f3ebb6e98015fabb9af Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:41:39 -0700 Subject: [PATCH 05/21] Add a trailing newline to the package.json --- src/publish.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/publish.coffee b/src/publish.coffee index 0b03e79cf..6d3140395 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -233,8 +233,8 @@ class Publish extends Command saveMetadata: (pack) -> metadataPath = path.resolve('package.json') - out = JSON.stringify(pack, null, 2) - fs.writeFileSync(metadataPath, out) + metadataJson = JSON.stringify(pack, null, 2) + fs.writeFileSync(metadataPath, "#{metadataJson}\n") loadRepository: -> currentDirectory = process.cwd() From 5a551bdbaeb0b44bece692bfd7d76ce4530a0fb0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:44:25 -0700 Subject: [PATCH 06/21] Handle git add failing --- src/publish.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 6d3140395..546aca206 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -261,8 +261,10 @@ class Publish extends Command process.stdout.write("#{message}\n") @setPackageName pack, name, => @spawn 'git', ['add', 'package.json'], (addCode) => + return callback('`git add package.json` failed') unless addCode is 0 + @spawn 'git', ['commit', '-m', "#{message}"], (code, stderr='', stdout='') => - if code is 0 or addCode is 0 + if code is 0 callback() else callback('Failed to commit package.json') From 0f31c1802eed65d49faa6220f5cbeb04eb6f05be Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:45:08 -0700 Subject: [PATCH 07/21] Remove unneeded quotes --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 546aca206..f1d7c2ba7 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -263,7 +263,7 @@ class Publish extends Command @spawn 'git', ['add', 'package.json'], (addCode) => return callback('`git add package.json` failed') unless addCode is 0 - @spawn 'git', ['commit', '-m', "#{message}"], (code, stderr='', stdout='') => + @spawn 'git', ['commit', '-m', message], (code, stderr='', stdout='') => if code is 0 callback() else From c92b1bc48701a852e99740aedb4884bf5a49845f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:48:37 -0700 Subject: [PATCH 08/21] Log output from failed git add/commit commands --- src/publish.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/publish.coffee b/src/publish.coffee index f1d7c2ba7..144963232 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -260,14 +260,17 @@ class Publish extends Command message = "Renaming #{pack.name} to #{name}" process.stdout.write("#{message}\n") @setPackageName pack, name, => - @spawn 'git', ['add', 'package.json'], (addCode) => - return callback('`git add package.json` failed') unless addCode is 0 + @spawn 'git', ['add', 'package.json'], (code, stderr='', stdout='') => + unless code is 0 + addOutput = "#{stdout}\n#{stderr}".trim() + return callback("`git add package.json` failed: #{addOutput}") @spawn 'git', ['commit', '-m', message], (code, stderr='', stdout='') => if code is 0 callback() else - callback('Failed to commit package.json') + commitOutput = "#{stdout}\n#{stderr}".trim() + callback("Failed to commit package.json: #{commitOutput}") else # Just fall through if the name is empty callback() From 25687c25103ebe3eb423481782e1c1906ec7f179 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:49:08 -0700 Subject: [PATCH 09/21] Don't touch package.json if it is good to go --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 144963232..35c4b644b 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -256,7 +256,7 @@ class Publish extends Command # Rename package if necessary renamePackage: (pack, name, callback) -> - if name?.length > 0 + if name?.length > 0 and pack.name isnt name message = "Renaming #{pack.name} to #{name}" process.stdout.write("#{message}\n") @setPackageName pack, name, => From 9664bccd5a54660fb8095bfc299f322b9b0c0dfb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:51:28 -0700 Subject: [PATCH 10/21] Write package.json async and report error --- src/publish.coffee | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/publish.coffee b/src/publish.coffee index 35c4b644b..a19dc5428 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -231,10 +231,10 @@ class Publish extends Command catch error throw new Error("Error parsing package.json file: #{error.message}") - saveMetadata: (pack) -> + saveMetadata: (pack, callback) -> metadataPath = path.resolve('package.json') metadataJson = JSON.stringify(pack, null, 2) - fs.writeFileSync(metadataPath, "#{metadataJson}\n") + fs.writeFile(metadataPath, "#{metadataJson}\n", callback) loadRepository: -> currentDirectory = process.cwd() @@ -259,7 +259,10 @@ class Publish extends Command 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() @@ -276,12 +279,8 @@ class Publish extends Command callback() setPackageName: (pack, name, callback) -> - if pack.name is name - return callback(new Error('New package name matches old package name')) - pack.name = name - @saveMetadata(pack) - callback() + @saveMetadata(pack, callback) # Run the publish command with the given options run: (options) -> From 271f5ae3bdf0825bce4baa1a3c503f992a416050 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:51:57 -0700 Subject: [PATCH 11/21] Log success/failure markers --- src/publish.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/publish.coffee b/src/publish.coffee index a19dc5428..a3b14aeb3 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -261,17 +261,21 @@ class Publish extends Command process.stdout.write("#{message}\n") @setPackageName pack, name, (error) => if error? + @logFailure() return callback(error) @spawn 'git', ['add', 'package.json'], (code, stderr='', stdout='') => unless code is 0 + @logFailure() addOutput = "#{stdout}\n#{stderr}".trim() return callback("`git add package.json` failed: #{addOutput}") @spawn 'git', ['commit', '-m', message], (code, stderr='', stdout='') => if code is 0 + @logSuccess() callback() else + @logFailure() commitOutput = "#{stdout}\n#{stderr}".trim() callback("Failed to commit package.json: #{commitOutput}") else From f2198f19911eab9b7a16e604d84c48a60635eaee Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:52:31 -0700 Subject: [PATCH 12/21] Don't write newline until completion --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index a3b14aeb3..5da1c32fc 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -258,7 +258,7 @@ class Publish extends Command renamePackage: (pack, name, callback) -> if name?.length > 0 and pack.name isnt name message = "Renaming #{pack.name} to #{name}" - process.stdout.write("#{message}\n") + process.stdout.write("#{message}") @setPackageName pack, name, (error) => if error? @logFailure() From e69bfc68d89dbed8b8c31512e5583ad484db9ae1 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 16:55:05 -0700 Subject: [PATCH 13/21] Remove unneeded curlies --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 5da1c32fc..ff1c014ca 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -258,7 +258,7 @@ class Publish extends Command renamePackage: (pack, name, callback) -> if name?.length > 0 and pack.name isnt name message = "Renaming #{pack.name} to #{name}" - process.stdout.write("#{message}") + process.stdout.write(message) @setPackageName pack, name, (error) => if error? @logFailure() From 1b3177c6a99dbea1d46c9feb025ef9a57f30e6d5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:03:56 -0700 Subject: [PATCH 14/21] Add trailing space to status message --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index ff1c014ca..c27ac4701 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -257,7 +257,7 @@ class Publish extends Command # Rename package if necessary renamePackage: (pack, name, callback) -> if name?.length > 0 and pack.name isnt name - message = "Renaming #{pack.name} to #{name}" + message = "Renaming #{pack.name} to #{name} " process.stdout.write(message) @setPackageName pack, name, (error) => if error? From 0726cbf329b5d338a61947e04bae406be43ac74b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:11:21 -0700 Subject: [PATCH 15/21] Use setting from .apmrc file In case someone needs to override where git is located like they do sometimes with npm --- src/config.coffee | 7 +++++++ src/publish.coffee | 28 +++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/config.coffee b/src/config.coffee index 3cf04d011..04a30254e 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -1,6 +1,7 @@ child_process = require 'child_process' fs = require 'fs' path = require 'path' +npm = require 'npm' module.exports = getHomeDirectory: -> @@ -81,3 +82,9 @@ module.exports = vs2010Path = path.join(@x86ProgramFilesDirectory(), "Microsoft Visual Studio 10.0", "Common7", "IDE") return '2010' if fs.existsSync(vs2010Path) + + getSetting: (key, callback) -> + npmOptions = + userconfig: @getUserConfigPath() + globalconfig: @getGlobalConfigPath() + npm.load npmOptions, -> callback(npm.config.get(key)) diff --git a/src/publish.coffee b/src/publish.coffee index c27ac4701..6fb13f743 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -264,20 +264,22 @@ class Publish extends Command @logFailure() return callback(error) - @spawn 'git', ['add', 'package.json'], (code, stderr='', stdout='') => - unless code is 0 - @logFailure() - addOutput = "#{stdout}\n#{stderr}".trim() - return callback("`git add package.json` failed: #{addOutput}") - - @spawn 'git', ['commit', '-m', message], (code, stderr='', stdout='') => - if code is 0 - @logSuccess() - callback() - else + config.getSetting 'git', (gitCommand) -> + gitCommand ?= 'git' + @spawn gitCommand, ['add', 'package.json'], (code, stderr='', stdout='') => + unless code is 0 @logFailure() - commitOutput = "#{stdout}\n#{stderr}".trim() - callback("Failed to commit package.json: #{commitOutput}") + addOutput = "#{stdout}\n#{stderr}".trim() + return callback("`git add package.json` failed: #{addOutput}") + + @spawn gitCommand, ['commit', '-m', message], (code, stderr='', stdout='') => + if code is 0 + @logSuccess() + callback() + else + @logFailure() + commitOutput = "#{stdout}\n#{stderr}".trim() + callback("Failed to commit package.json: #{commitOutput}") else # Just fall through if the name is empty callback() From b96675fe4ab9da07ac2dd869563de3a3cb2376e5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:12:20 -0700 Subject: [PATCH 16/21] Use fat arrow --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 6fb13f743..03cf43bb1 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -264,7 +264,7 @@ class Publish extends Command @logFailure() return callback(error) - config.getSetting 'git', (gitCommand) -> + config.getSetting 'git', (gitCommand) => gitCommand ?= 'git' @spawn gitCommand, ['add', 'package.json'], (code, stderr='', stdout='') => unless code is 0 From d25ed1c9873187858701d8ea10fbf52809a3d03c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:14:52 -0700 Subject: [PATCH 17/21] Use ? instead of || --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 03cf43bb1..3d48c257a 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -204,7 +204,7 @@ class Publish extends Command options = remaining.shift() if remaining.length >= 2 callback = remaining.shift() - process.stdout.write "Publishing #{options.rename || pack.name}@#{tag} " + process.stdout.write "Publishing #{options.rename ? pack.name}@#{tag} " @createPackageVersion pack.name, tag, options, (error) => if error? @logFailure() From 3a493f1a54a0ffaf15ea68bee551ad898e8f78a5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:15:02 -0700 Subject: [PATCH 18/21] Use or instead of || --- src/publish.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index 3d48c257a..688dc3714 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -204,7 +204,7 @@ class Publish extends Command options = remaining.shift() if remaining.length >= 2 callback = remaining.shift() - process.stdout.write "Publishing #{options.rename ? pack.name}@#{tag} " + process.stdout.write "Publishing #{options.rename or pack.name}@#{tag} " @createPackageVersion pack.name, tag, options, (error) => if error? @logFailure() From f8185a3e2060d09fe8e3ce78b4f75266ded88e3f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:21:50 -0700 Subject: [PATCH 19/21] Use git .apmrc setting in develop command --- src/develop.coffee | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/develop.coffee b/src/develop.coffee index bf475b793..e6d1811b7 100644 --- a/src/develop.coffee +++ b/src/develop.coffee @@ -54,16 +54,17 @@ class Develop extends Command callback("Request for package information failed: #{message}") cloneRepository: (repoUrl, packageDirectory, options) -> - command = "git" - args = ['clone', '--recursive', repoUrl, packageDirectory] - process.stdout.write "Cloning #{repoUrl} " - @spawn command, args, (code, stderr='', stdout='') => - if code is 0 - @logSuccess() - @installDependencies(packageDirectory, options) - else - @logFailure() - options.callback("#{stdout}\n#{stderr}".trim()) + config.getSetting 'git', (command) => + command ?= "git" + args = ['clone', '--recursive', repoUrl, packageDirectory] + process.stdout.write "Cloning #{repoUrl} " + @spawn command, args, (code, stderr='', stdout='') => + if code is 0 + @logSuccess() + @installDependencies(packageDirectory, options) + else + @logFailure() + options.callback("#{stdout}\n#{stderr}".trim()) installDependencies: (packageDirectory, options) -> process.chdir(packageDirectory) From cf4f79b44fb5fe1dcde1d3a70eeab09613f6bdb0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:34:47 -0700 Subject: [PATCH 20/21] Set originalName based on rename option --- src/publish.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/publish.coffee b/src/publish.coffee index 688dc3714..cf9fc7ada 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -306,9 +306,8 @@ class Publish extends Command return callback(error) if version?.length > 0 or rename?.length > 0 - unless version?.length > 0 - version = 'patch' - originalName = pack.name + version = 'patch' unless version?.length > 0 + originalName = pack.name if rename?.length > 0 @registerPackage pack, (error, firstTimePublishing) => return callback(error) if error? From 6522277ebc4ad50c14c9c95460f8aa94328fd6b2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jul 2014 17:39:29 -0700 Subject: [PATCH 21/21] Log error when package current/new name is the same --- src/publish.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/publish.coffee b/src/publish.coffee index cf9fc7ada..32abf2577 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -256,7 +256,9 @@ class Publish extends Command # Rename package if necessary renamePackage: (pack, name, callback) -> - if name?.length > 0 and pack.name isnt name + if name?.length > 0 + return callback('The new package name must be different than the name in the package.json file') if pack.name is name + message = "Renaming #{pack.name} to #{name} " process.stdout.write(message) @setPackageName pack, name, (error) =>