@gravityforms/gulp-tasks
Version:
Configurable Gulp tasks for use in Gravity Forms projects.
30 lines (24 loc) • 1.01 kB
JavaScript
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { deleteDirectory, execShellCommand } from './util.js';
const __dirname = path.dirname( fileURLToPath( import.meta.url ) );
const packagesDir = path.resolve( __dirname, '../../../' );
const utilsPath = path.join( packagesDir, 'react-utils' );
const gulpTasksPath = path.join( packagesDir, 'gulp-tasks' );
async function init() {
await deleteDirectory( path.join( path.join( utilsPath, 'dist' ) ) );
await execShellCommand( `cd "${ gulpTasksPath }" && cross-env NODE_ENV=reactutilsdev npx webpack && cross-env NODE_ENV=reactutilsprod npx webpack --mode production`, true );
}
( async () => {
try {
if ( ! fs.existsSync( utilsPath ) ) {
console.log( 'react-utils package not found. Skipping dist generation for that package.' );
return;
}
await init();
} catch ( err ) {
console.error( 'An error occurred during generating react utils dist files: ', err );
}
} )();