Class Npmrc

java.lang.Object
jenkins.plugins.nodejs.configfiles.Npmrc

public class Npmrc extends Object
Npm config file parser.
Since:
1.0
Author:
Nikolas Falco
  • Constructor Details

    • Npmrc

      public Npmrc()
  • Method Details

    • load

      public static Npmrc load(File file) throws IOException
      Parse the given file and store internally all user settings and comments.
      Parameters:
      file - a valid npmrc user config file content.
      Returns:
      the instance of parsed user config.
      Throws:
      IOException - in case of I/O failure during file read
    • from

      public void from(String content)
      Parse the given content and store internally all user settings and comments.
      Parameters:
      content - a valid npmrc user config content.
    • addComment

      public void addComment(String comment)
      Add a comment line at the end of the file.
      Parameters:
      comment - the text content without the ';' prefix
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • save

      public void save(File file) throws IOException
      Write the content of user config to a file.
      Parameters:
      file - the destination file
      Throws:
      IOException - in case of I/O write error
    • contains

      public boolean contains(String key)
      Returns true if this map contains a user config for the specified key.
      Parameters:
      key - user setting whose presence in this config
      Returns:
      true if this config already contains the specified key
    • get

      public String get(String key)
      Get the value for the specified property key.
      Parameters:
      key - user config entry key
      Returns:
      the property value
    • set

      public String set(String key, String value)
      Set the value for the specified property key. If key already present it will be override.
      Parameters:
      key - property key
      value - property value
      Returns:
      the old value associated to the setting key, null otherwise
    • set

      public boolean set(String key, boolean value)
      Set the value for the specified property key. If key already present it will be override.
      Parameters:
      key - property key
      value - property value
      Returns:
      false the old value associated to the property key, true otherwise
    • getAsBoolean

      public Boolean getAsBoolean(String key)
      Get the value for the specified property key as a boolean.
      Parameters:
      key - user config entry key
      Returns:
      a boolean represented by the property value or null if the key doesn't exist or the value associated is empty.
    • getAsNumber

      public Integer getAsNumber(String key)
      Get the value for the specified property key as a number.
      Parameters:
      key - user config entry key
      Returns:
      an integer represented by the property value or null if the key doesn't exist or the value associated is empty.