How to use the @wordpress/hooks.didAction function in @wordpress/hooks

To help you get started, we’ve selected a few @wordpress/hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pento / testpress / src / services / grunt / index.js View on Github external
// 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',
github DefinitelyTyped / DefinitelyTyped / types / wordpress__hooks / wordpress__hooks-tests.ts View on Github external
// $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();
github pento / testpress / src / services / docker / index.js View on Github external
], {
		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();
	}
}
github pento / testpress / src / services / npm-watcher / index.js View on Github external
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, [
github pento / testpress / src / services / npm-watcher / index.js View on Github external
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' ],