Skip to content

Commit

Permalink
feat(cli): send config, rootDir, and webDir to custom platform hooks (#…
Browse files Browse the repository at this point in the history
…4084)

Co-authored-by: Dan Imhoff <dwieeb@gmail.com>
  • Loading branch information
IT-MikeS and imhoffd committed Jan 19, 2021
1 parent e54a4f6 commit 13e9860
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export async function wait(time: number): Promise<void> {
}

export async function runPlatformHook(
config: Config,
platformDir: string,
hook: string,
): Promise<void> {
Expand All @@ -168,6 +169,9 @@ export async function runPlatformHook(
cwd: platformDir,
env: {
INIT_CWD: platformDir,
CAPACITOR_ROOT_DIR: config.app.rootDir,
CAPACITOR_WEB_DIR: config.app.webDirAbs,
CAPACITOR_CONFIG: JSON.stringify(config.app.extConfig),
...process.env,
},
});
Expand Down
2 changes: 1 addition & 1 deletion cli/src/tasks/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function addCommand(
if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) {
const platformDir = resolvePlatform(config, selectedPlatformName);
if (platformDir) {
await runPlatformHook(platformDir, 'capacitor:add');
await runPlatformHook(config, platformDir, 'capacitor:add');
} else {
let msg = `Platform ${c.input(selectedPlatformName)} not found.`;

Expand Down
2 changes: 1 addition & 1 deletion cli/src/tasks/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function copyCommand(
if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) {
const platformDir = resolvePlatform(config, selectedPlatformName);
if (platformDir) {
await runPlatformHook(platformDir, 'capacitor:copy');
await runPlatformHook(config, platformDir, 'capacitor:copy');
} else {
logger.error(`Platform ${c.input(selectedPlatformName)} not found.`);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/tasks/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function openCommand(
if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) {
const platformDir = resolvePlatform(config, selectedPlatformName);
if (platformDir) {
await runPlatformHook(platformDir, 'capacitor:open');
await runPlatformHook(config, platformDir, 'capacitor:open');
} else {
logger.error(`Platform ${c.input(selectedPlatformName)} not found.`);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/tasks/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function runCommand(
if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) {
const platformDir = resolvePlatform(config, selectedPlatformName);
if (platformDir) {
await runPlatformHook(platformDir, 'capacitor:run');
await runPlatformHook(config, platformDir, 'capacitor:run');
} else {
logger.error(`Platform ${c.input(selectedPlatformName)} not found.`);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/tasks/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function updateCommand(
if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) {
const platformDir = resolvePlatform(config, selectedPlatformName);
if (platformDir) {
await runPlatformHook(platformDir, 'capacitor:update');
await runPlatformHook(config, platformDir, 'capacitor:update');
} else {
logger.error(`Platform ${c.input(selectedPlatformName)} not found.`);
}
Expand Down

0 comments on commit 13e9860

Please sign in to comment.