Interface IConfigComponents

{@link http://gruntjs.com/api/grunt.config}

Hierarchy

Index

Call signatures

Methods

Call signatures

(prop: string, value: any): any

Get or set a value from the project's Grunt configuration. This method serves as an alias to other methods; if two arguments are passed, grunt.config.set is called, otherwise grunt.config.get is called.

Parameters

  • prop: string
  • value: any

Returns

any

(prop: string): any

Parameters

  • prop: string

Returns

any

Methods

public escape(propString: string): string

Escape '.' dots in the given propString. This should be used for property names that contain dots.

Parameters

  • propString: string

Returns

string

public get(prop: string): T

Get a value from the project's Grunt configuration. If prop is specified, that property's value is returned, or null if that property is not defined. If prop isn't specified, a copy of the entire config object is returned. Templates strings will be recursively processed using the grunt.config.process method.

note

Although this accepts a generic type, you may still get the wrong typed value.

Parameters

  • prop: string

Returns

T

public get(): ConfigModule

Returns

ConfigModule

public getRaw(prop: string): T

Get a raw value from the project's Grunt configuration, without processing <% %> template strings. If prop is specified, that property's value is returned, or null if that property is not defined. If prop isn't specified, a copy of the entire config object is returned.

Parameters

  • prop: string

Returns

T

public init(config: IProjectConfig)

Initialize a configuration object for the current project. The specified configObject is used by tasks and can be accessed using the grunt.config method. Nearly every project's Gruntfile will call this method.

Parameters

public initConfig(config: IProjectConfig)

An alias

see

grunt.config.ConfigModule.init

Parameters

public process(value: string): T

Process a value, recursively expanding <% %> templates (via the grunt.template.process method) in the context of the Grunt config, as they are encountered. this method is called automatically by grunt.config.get but not by grunt.config.getRaw.

If any retrieved value is entirely a single '<%= foo %>' or '<%= foo.bar %>' template string, and the specified foo or foo.bar property is a non-string (and not null or undefined) value, it will be expanded to the actual value. That, combined with grunt's task system automatically flattening arrays, can be extremely useful.

Parameters

  • value: string

Returns

T

public requires(prop: string, andProps?: Array<string>)

Fail the current task if one or more required config properties is missing, null or undefined. One or more string or array config properties may be specified.

Parameters

  • prop: string
  • andProps?: Array<string> optional

public requires(prop: Array<string>, andProps?: Array<string[]>)

Parameters

  • prop: Array<string>
  • andProps?: Array<string[]> optional

public set(prop: string, value: T): T

Set a value into the project's Grunt configuration.

note

any specified <% %> template strings will only be processed when config data is retrieved.

Parameters

  • prop: string
  • value: T

Returns

T