Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run lifecycle hooks for specific codebases #6011

Merged
merged 3 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Run lifecycle hooks for specific codebases. (#6011)
4 changes: 3 additions & 1 deletion src/deploy/lifecycleHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import * as clc from "colorette";
import * as childProcess from "child_process";
import { FirebaseError } from "../error";
const needProjectId = require("../projectUtils").needProjectId;

Check warning on line 5 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value

Check warning on line 5 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe member access .needProjectId on an `any` value

Check warning on line 5 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Require statement not part of import statement
import { logger } from "../logger";
import * as path from "path";
import { Options } from "../options";

function runCommand(command: string, childOptions: childProcess.SpawnOptions) {

Check warning on line 10 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Missing return type on function
const escapedCommand = command.replace(/\"/g, '\\"');

Check warning on line 11 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unnecessary escape character: \"
const translatedCommand =
'"' +
process.execPath +
Expand All @@ -31,7 +31,7 @@
if (signal) {
reject(new Error("Command terminated with signal " + signal));
} else if (code !== 0) {
reject(new Error("Command terminated with non-zero exit code " + code));

Check warning on line 34 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Operands of '+' operation must either be both strings or both numbers. Consider using a template literal
} else {
resolve();
}
Expand All @@ -39,9 +39,9 @@
});
}

function getChildEnvironment(target: string, overallOptions: any, config: any) {

Check warning on line 42 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Missing return type on function

Check warning on line 42 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type

Check warning on line 42 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type
// active project ID
const projectId = needProjectId(overallOptions);

Check warning on line 44 in src/deploy/lifecycleHooks.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unsafe assignment of an `any` value
// root directory where firebase.json can be found
const projectDir = overallOptions.projectRoot;
// location of hosting site or functions deploy, defaults project directory
Expand Down Expand Up @@ -127,7 +127,6 @@

let onlyTargets = options.only.split(",");
if (onlyTargets.includes(target)) {
// If the target matches entirely then all instances should be included.
return targetConfigs;
}

Expand All @@ -140,6 +139,9 @@
});

return targetConfigs.filter((config: any) => {
if (target === "functions") {
return onlyTargets.includes(config.codebase);
}
return !config.target || onlyTargets.includes(config.target);
});
}
Expand Down
Loading