Merge pull request #25 from foopoiuyt/feature/tag

Added support for setting tag on npm publish
This commit is contained in:
Don
2017-02-15 13:31:37 -08:00
committed by GitHub
3 changed files with 31 additions and 3 deletions
+4
View File
@@ -11,6 +11,10 @@ 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)
* **access* - the access level to use for scoped packages (does not set
one by default)
The following secret values can be set to configure the plugin.
+12
View File
@@ -58,6 +58,16 @@ func main() {
Name: "env-file",
Usage: "source env file",
},
cli.StringFlag{
Name: "tag",
Usage: "NPM publish tag",
EnvVar: "PLUGIN_TAG",
},
cli.StringFlag{
Name: "access",
Usage: "NPM scoped package access",
EnvVar: "PLUGIN_ACCESS",
},
}
if err := app.Run(os.Args); err != nil {
@@ -79,6 +89,8 @@ func run(c *cli.Context) error {
Registry: c.String("registry"),
Folder: c.String("folder"),
SkipVerify: c.Bool("skip_verify"),
Tag: c.String("tag"),
Access: c.String("access"),
},
}
+15 -3
View File
@@ -26,6 +26,8 @@ type (
Registry string
Folder string
SkipVerify bool
Tag string
Access string
}
npmPackage struct {
@@ -81,7 +83,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 +309,18 @@ 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 {
commandArgs := []string{"publish"};
if len(config.Tag) != 0 {
commandArgs = append(commandArgs, "--tag", config.Tag);
}
if len(config.Access) != 0 {
commandArgs = append(commandArgs, "--access", config.Access);
}
return exec.Command("npm", commandArgs...);
}
// trace writes each command to standard error (preceded by a $ ) before it