FirebaseFunctionsToolingPlan.create constructor

FirebaseFunctionsToolingPlan.create({
  1. required Directory functionsDirectory,
})

Creates a command plan based on the current Functions directory.

Functionsディレクトリの現在の状態に基づいてコマンド計画を作成します。

Implementation

factory FirebaseFunctionsToolingPlan.create({
  required Directory functionsDirectory,
}) {
  final executableSuffix = Platform.isWindows ? ".cmd" : "";
  String localExecutable(String name) =>
      "node_modules/.bin/$name$executableSuffix";
  return FirebaseFunctionsToolingPlan._(
    initializeJest:
        !File("${functionsDirectory.path}/jest.config.js").existsSync(),
    initializeJestCommand: [
      localExecutable("ts-jest"),
      "config:init",
    ],
    fixLintCommand: [
      localExecutable("eslint"),
      "--ext",
      ".js,.ts",
      "--fix",
      ".",
    ],
  );
}