All files / src/util grunt-config.js

100% Statements 2/2
100% Branches 4/4
100% Functions 1/1
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                    1x               4x            
/**
 * This file defines the grunt-config helper for creating an AST config object.
 *
 * The object itself is an AST-Config object, but it is set up specifically to
 * work well with the default Gruntfile object in WP Make. This makes the
 * get and set config methods on the AST-Config object work well for the
 * Gruntfile config specifically.
 */
 
// Require dependencies
import ASTConfig from './ast-config.js';
 
/**
 * Export the function for creating a Gruntfile flavored AST config.
 *
 * @param  {String} contents The stringified Gruntfile contents.
 * @return {Object}          The AST-Config object for the Gruntfile.
 */
export default ( contents, AST = ASTConfig ) => new AST( contents, {
	type: 'gruntfile',
	query: 'gruntConfig',
	queryMethod: 'callExpression',
	filter: val => val.arguments.at( 1 )
} );