mirror of
https://github.com/drone-plugins/drone-npm.git
synced 2026-06-04 18:23:52 +08:00
Add support for --access in addition
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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"),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user