Added support for setting tag on npm publish

This commit is contained in:
Stephan Szabo
2017-02-10 15:04:50 -08:00
parent 688acc58f2
commit a0dfdb13e3
3 changed files with 16 additions and 3 deletions
+2
View File
@@ -11,6 +11,8 @@ The following parameters are used to configure the plugin:
* **registry** - the registry URL to use (https://registry.npmjs.org by default)
* **folder** - the folder, relative to the workspace, containing the library
(uses the workspace directory, by default)
* **tag** - the tag to use when publishing the package (does not set
one by default)
The following secret values can be set to configure the plugin.
+6
View File
@@ -58,6 +58,11 @@ func main() {
Name: "env-file",
Usage: "source env file",
},
cli.StringFlag{
Name: "tag",
Usage: "NPM publish tag",
EnvVar: "PLUGIN_TAG",
},
}
if err := app.Run(os.Args); err != nil {
@@ -79,6 +84,7 @@ func run(c *cli.Context) error {
Registry: c.String("registry"),
Folder: c.String("folder"),
SkipVerify: c.Bool("skip_verify"),
Tag: c.String("tag"),
},
}
+8 -3
View File
@@ -26,6 +26,7 @@ type (
Registry string
Folder string
SkipVerify bool
Tag string
}
npmPackage struct {
@@ -81,7 +82,7 @@ func (p Plugin) Exec() error {
log.Info("Publishing package")
// run the publish command
return runCommand(publishCommand(), p.Config.Folder)
return runCommand(publishCommand(p.Config), p.Config.Folder)
}
return nil
@@ -307,8 +308,12 @@ func packageVersionsCommand(name string) *exec.Cmd {
}
// publishCommand runs the publish command
func publishCommand() *exec.Cmd {
return exec.Command("npm", "publish")
func publishCommand(config Config) *exec.Cmd {
if len(config.Tag) == 0 {
return exec.Command("npm", "publish");
} else {
return exec.Command("npm", "publish", "--tag", config.Tag);
}
}
// trace writes each command to standard error (preceded by a $ ) before it