Class Npmrc
java.lang.Object
jenkins.plugins.nodejs.configfiles.Npmrc
Npm config file parser.
- Since:
- 1.0
- Author:
- Nikolas Falco
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addComment
(String comment) Add a comment line at the end of the file.boolean
Returns true if this map contains a user config for the specified key.void
Parse the given content and store internally all user settings and comments.Get the value for the specified property key.getAsBoolean
(String key) Get the value for the specified property key as a boolean.getAsNumber
(String key) Get the value for the specified property key as a number.static Npmrc
Parse the given file and store internally all user settings and comments.void
Write the content of user config to a file.boolean
Set the value for the specified property key.Set the value for the specified property key.toString()
-
Constructor Details
-
Npmrc
public Npmrc()
-
-
Method Details
-
load
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
Parse the given content and store internally all user settings and comments.- Parameters:
content
- a valid npmrc user config content.
-
addComment
Add a comment line at the end of the file.- Parameters:
comment
- the text content without the ';' prefix
-
toString
-
save
Write the content of user config to a file.- Parameters:
file
- the destination file- Throws:
IOException
- in case of I/O write error
-
contains
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
Get the value for the specified property key.- Parameters:
key
- user config entry key- Returns:
- the property value
-
set
Set the value for the specified property key. If key already present it will be override.- Parameters:
key
- property keyvalue
- property value- Returns:
- the old value associated to the setting key, null otherwise
-
set
Set the value for the specified property key. If key already present it will be override.- Parameters:
key
- property keyvalue
- property value- Returns:
- false the old value associated to the property key, true otherwise
-
getAsBoolean
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
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.
-