diff --git a/cli/src/common.ts b/cli/src/common.ts index ac7aad51f..6d1701970 100644 --- a/cli/src/common.ts +++ b/cli/src/common.ts @@ -6,6 +6,7 @@ import c from './colors'; import type { Config, PackageJson } from './definitions'; import { fatal } from './errors'; import { output, logger } from './log'; +import { getPlugins } from './plugin'; import { findNXMonorepoRoot, isNXMonorepo } from './util/monorepotools'; import { resolveNode } from './util/node'; import { runCommand } from './util/subprocess'; @@ -162,6 +163,20 @@ export async function wait(time: number): Promise { return new Promise(resolve => setTimeout(resolve, time)); } +export async function runHooks( + config: Config, + platformName: string, + dir: string, + hook: string, +): Promise { + await runPlatformHook(config, platformName, dir, hook); + + const allPlugins = await getPlugins(config, platformName); + allPlugins.forEach(async p => { + await runPlatformHook(config, platformName, p.rootPath, hook); + }); +} + export async function runPlatformHook( config: Config, platformName: string, diff --git a/cli/src/tasks/copy.ts b/cli/src/tasks/copy.ts index f451762d8..5513398d7 100644 --- a/cli/src/tasks/copy.ts +++ b/cli/src/tasks/copy.ts @@ -5,6 +5,7 @@ import c from '../colors'; import { checkWebDir, resolvePlatform, + runHooks, runPlatformHook, runTask, isValidPlatform, @@ -70,7 +71,7 @@ export async function copy( throw result; } - await runPlatformHook( + await runHooks( config, platformName, config.app.rootDir, @@ -190,7 +191,7 @@ export async function copy( } }); - await runPlatformHook( + await runHooks( config, platformName, config.app.rootDir, diff --git a/cli/src/tasks/sync.ts b/cli/src/tasks/sync.ts index a80f93fef..f90c20ead 100644 --- a/cli/src/tasks/sync.ts +++ b/cli/src/tasks/sync.ts @@ -4,7 +4,7 @@ import { checkWebDir, selectPlatforms, isValidPlatform, - runPlatformHook, + runHooks, } from '../common'; import type { Config } from '../definitions'; import { fatal, isFatal } from '../errors'; @@ -63,7 +63,7 @@ export async function sync( deployment: boolean, inline = false, ): Promise { - await runPlatformHook( + await runHooks( config, platformName, config.app.rootDir, @@ -77,7 +77,7 @@ export async function sync( } await update(config, platformName, deployment); - await runPlatformHook( + await runHooks( config, platformName, config.app.rootDir, diff --git a/cli/src/tasks/update.ts b/cli/src/tasks/update.ts index f1add4074..7a7d22c0e 100644 --- a/cli/src/tasks/update.ts +++ b/cli/src/tasks/update.ts @@ -4,6 +4,7 @@ import { check, checkPackage, resolvePlatform, + runHooks, runPlatformHook, runTask, selectPlatforms, @@ -84,7 +85,7 @@ export async function update( deployment: boolean, ): Promise { await runTask(c.success(c.strong(`update ${platformName}`)), async () => { - await runPlatformHook( + await runHooks( config, platformName, config.app.rootDir, @@ -97,7 +98,7 @@ export async function update( await updateAndroid(config); } - await runPlatformHook( + await runHooks( config, platformName, config.app.rootDir,