Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// We only need to run `grunt watch` on WordPress folder updates.
if ( folderPref && 'wordpress-folder' !== folderPref ) {
return;
}
setStatus( 'grunt', 'building' );
debug( 'Preparing to run `grunt watch`' );
if ( watchProcess ) {
debug( 'Ending previous `grunt watch` process' );
watchProcess.kill();
watchProcess = null;
}
if ( ! didAction( 'npm_install_finished' ) ) {
debug( "Bailing, `npm install` isn't finished" );
return;
}
if ( ! cwd ) {
debug( "Bailing, WordPress folder isn't set" );
return;
}
const grunt = cwd + '/node_modules/grunt/bin/grunt';
debug( 'Starting `grunt watch`' );
watchProcess = spawn( NODE_BIN, [
grunt,
'watch',
'--dev',
// $ExpectType string | null
hooks.currentAction();
// $ExpectType string | null
hooks.currentFilter();
// $ExpectType boolean
hooks.doingAction();
// $ExpectType boolean
hooks.doingAction('my-action');
// $ExpectType boolean
hooks.doingFilter();
// $ExpectType boolean
hooks.doingFilter('my-action');
// $ExpectType number
hooks.didAction('my-action');
// $ExpectType number
hooks.didFilter('my-filter');
// $ExpectType HookMap
hooks.actions;
// $ExpectType HookMap
hooks.filters;
(() => {
const {
// $ExpectType HookMap
actions,
// $ExpectType HookMap
filters,
} = hooks.createHooks();
], {
cwd: TOOLS_DIR,
encoding: 'utf8',
env: {
PATH: process.env.PATH,
...dockerEnv,
},
} ).catch( ( { stderr } ) => debug( stderr ) );
debug( 'Docker containers started' );
setStatus( 'docker', 'ready' );
addAction( 'grunt_watch_first_run_finished', 'installWordPress', installWordPress );
if ( didAction( 'grunt_watch_first_run_finished' ) ) {
installWordPress();
}
}
function runNPMInstall( folderPref ) {
debug( '(%s) Preparing for `npm install`', folderPref );
if ( installProcesses[ folderPref ] ) {
debug( '(%s) Ending previous `npm install` process', folderPref );
installProcesses[ folderPref ].kill();
installProcesses[ folderPref ] = null;
}
if ( ! didAction( 'updated_node_and_npm' ) ) {
debug( "(%s) Bailing, node hasn't finished installing", folderPref );
return;
}
if ( ! cwds[ folderPref ] ) {
debug( "(%s) Bailing, folder isn't set", folderPref );
return;
}
if ( ! existsSync( NPM_CACHE_DIR ) ) {
debug( '(%s) Creating npm cache directory %s', folderPref, NPM_CACHE_DIR );
mkdirSync( NPM_CACHE_DIR );
}
debug( '(%s) Starting `npm install`', folderPref );
installProcesses[ folderPref ] = spawn( NODE_BIN, [
function runNPMDev( folderPref ) {
if ( 'gutenberg-folder' !== folderPref ) {
return;
}
debug( 'Preparing to run `npm run dev`' );
if ( devProcess ) {
debug( 'Ending previous `npm run dev` process' );
devProcess.kill();
devProcess = null;
}
if ( ! didAction( 'npm_install_finished' ) ) {
debug( "Bailing, `npm install` isn't finished" );
return;
}
if ( ! cwds[ 'gutenberg-folder' ] ) {
debug( "Bailing, Gutenberg folder isn't set" );
return;
}
debug( 'Starting `npm run dev`' );
devProcess = spawn( NODE_BIN, [
NPM_BIN,
'run',
'dev',
], {
cwd: cwds[ 'gutenberg-folder' ],