Add support for --access in addition

This commit is contained in:
Stephan Szabo
2017-02-10 17:00:08 -08:00
parent a0dfdb13e3
commit 5c8568f9ac
3 changed files with 19 additions and 4 deletions
+2
View File
@@ -13,6 +13,8 @@ The following parameters are used to configure the plugin:
(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.
+6
View File
@@ -63,6 +63,11 @@ func main() {
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 {
@@ -85,6 +90,7 @@ func run(c *cli.Context) error {
Folder: c.String("folder"),
SkipVerify: c.Bool("skip_verify"),
Tag: c.String("tag"),
Access: c.String("access"),
},
}
+11 -4
View File
@@ -27,6 +27,7 @@ type (
Folder string
SkipVerify bool
Tag string
Access string
}
npmPackage struct {
@@ -309,11 +310,17 @@ func packageVersionsCommand(name string) *exec.Cmd {
// publishCommand runs the publish command
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);
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