Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,42 @@ module.exports = function(grunt) {
} ],
},
'gutenberg-styles': {
options: {
process: function( content, srcpath ) {
if ( path.basename( srcpath ) !== 'registry.php' ) {
return content;
}

/*
* Gutenberg's generated style registry does not currently
* meet Core's PHP coding standards. Format its known keys
* while copying it so build jobs do not require PHP tooling.
*
* @ticket 65278
*/
const longestKey = 'dependencies';

return content.replace(
/^(\t\t)'(handle|path|dependencies)'\s*=>\s*([^\r\n]*)$/gm,
function( match, indentation, key, value ) {
const padding = ' '.repeat( longestKey.length - key.length + 1 );

if ( key === 'dependencies' ) {
value = value.replace(
/^array\((.*)\),$/,
function( array, dependencies ) {
dependencies = dependencies.trim();

return dependencies ? 'array( ' + dependencies + ' ),' : 'array(),';
}
);
}

return indentation + '\'' + key + '\'' + padding + '=> ' + value;
}
);
}
},
files: [ {
expand: true,
cwd: 'gutenberg/build/styles',
Expand Down
Loading