@gravityforms/gulp-tasks
Version:
Configurable Gulp tasks for use in Gravity Forms projects.
61 lines (58 loc) • 1.68 kB
JavaScript
const gulp = require( 'gulp' );
const stylelint = require( 'gulp-stylelint' );
const getConfig = require( '../../config' );
const { config } = getConfig();
const args = require( '../utils/get-args' );
/**
* @param {object} options {
* stylelintConfig = [],
* }
* @param {Array<object>} options.stylelintConfig
* @return
*/
async function stylelintProcess( {
stylelintConfig,
} ) {
return Promise.all( stylelintConfig.map( ( configObj ) => {
return new Promise( ( resolve ) => {
return gulp.src( configObj.src )
.pipe( stylelint( {
fix: ! args.nofix,
reporters: [
{ formatter: 'string', console: true },
],
} ) )
.pipe( gulp.dest( configObj.dest ) )
.on( 'end', () => resolve() );
} );
} ) );
}
module.exports = Object.assign( {}, {
admin() {
const stylelintConfig = config?.stylelint?.adminCss || [ {
src: [ `${ config.paths.css_src }/admin/**/*.pcss` ],
dest: `${ config.paths.css_src }/admin/`,
} ];
return stylelintProcess( {
stylelintConfig,
} );
},
common() {
const stylelintConfig = config?.stylelint?.commonCss || [ {
src: [ `${ config.paths.css_src }/common/**/*.pcss` ],
dest: `${ config.paths.css_src }/common/`,
} ];
return stylelintProcess( {
stylelintConfig,
} );
},
theme() {
const stylelintConfig = config?.stylelint?.themeCss || [ {
src: [ `${ config.paths.css_src }/theme/**/*.pcss` ],
dest: `${ config.paths.css_src }/theme/`,
} ];
return stylelintProcess( {
stylelintConfig,
} );
},
}, config?.tasks?.builtins?.stylelint || {} );