diff --git a/DOCS.md b/DOCS.md index f87c006..4043772 100644 --- a/DOCS.md +++ b/DOCS.md @@ -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. diff --git a/main.go b/main.go index a9edc2c..7f95539 100644 --- a/main.go +++ b/main.go @@ -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"), }, } diff --git a/plugin.go b/plugin.go index 790b3d5..29e6702 100644 --- a/plugin.go +++ b/plugin.go @@ -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