Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
buildEditorsForSamples( rootDir, bundleDir, testPath, samplesGlob ) {
const { stream, tools } = require( '@ckeditor/ckeditor5-dev-utils' );
const { utils: docsUtils } = require( '@ckeditor/ckeditor5-dev-docs' );
bundleDir = path.join( rootDir, bundleDir );
const ckeditor5DevBundler = require( '@ckeditor/ckeditor5-dev-bundler-rollup' )( {
ROOT_DIR: rootDir,
MODULE_DIR: {
esnext: ''
},
BUNDLE_DIR: bundleDir
} );
return docsUtils.getSamplesStream( rootDir, samplesGlob )
.pipe( gulpFilter( ( file ) => path.extname( file.path ) === '.js' ) )
.pipe( gulpRename( ( file ) => {
file.dirname = file.dirname.replace( '/docs/samples', '' );
} ) )
.pipe( stream.noop( ( file ) => {
const bundleConfig = docsUtils.getBundlerConfigFromSample( file.contents.toString( 'utf-8' ) );
bundleConfig.format = 'iife';
bundleConfig.path = file.path.match( /\/samples\/(.*)\.js$/ )[ 1 ];
const splitPath = bundleConfig.path.split( path.sep );
const packageName = splitPath[ 0 ];
// Clean the output paths.
return ckeditor5DevBundler.clean( bundleConfig )
// Then bundle a editor.
.then( () => ckeditor5DevBundler.generate( bundleConfig ) )