From 6fe08069abcf3017604c6f5ecd5f619902840d6a Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Sun, 14 Jan 2024 13:37:56 +0100 Subject: [PATCH] refactor: rename function params (#101) The functions responsible for ProjectManifest io took the path to the projects root directory, but always called it "work directory" or similar. Renamed the parameters to "projectPath" to better reflect their actual meaning. --- src/types/project-manifest.ts | 9 ++++----- src/utils/project-manifest-io.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/types/project-manifest.ts b/src/types/project-manifest.ts index 77b4340d..8def40bd 100644 --- a/src/types/project-manifest.ts +++ b/src/types/project-manifest.ts @@ -117,10 +117,9 @@ export function addTestable(manifest: UnityProjectManifest, name: DomainName) { } /** - * Determines the path to the package manifest based on the working - * directory (Root of Unity project). - * @param workingDirectory The working directory + * Determines the path to the package manifest based on the project directory. + * @param projectPath The root path of the Unity project */ -export function manifestPathFor(workingDirectory: string): string { - return path.join(workingDirectory, "Packages/manifest.json"); +export function manifestPathFor(projectPath: string): string { + return path.join(projectPath, "Packages/manifest.json"); } diff --git a/src/utils/project-manifest-io.ts b/src/utils/project-manifest-io.ts index 7d339e65..b1720a24 100644 --- a/src/utils/project-manifest-io.ts +++ b/src/utils/project-manifest-io.ts @@ -9,13 +9,13 @@ import fse from "fs-extra"; import path from "path"; /** - * Attempts to load the manifest from the path specified in env - * @param workingDirectory The working directory + * Attempts to load the manifest for a Unity project + * @param projectPath The path to the root of the project */ export const loadProjectManifest = function ( - workingDirectory: string + projectPath: string ): UnityProjectManifest | null { - const manifestPath = manifestPathFor(workingDirectory); + const manifestPath = manifestPathFor(projectPath); try { const text = fs.readFileSync(manifestPath, { encoding: "utf8" }); return JSON.parse(text); @@ -32,15 +32,15 @@ export const loadProjectManifest = function ( }; /** - * Save manifest json file to the path specified in env - * @param workingDirectory The working directory + * Saves a Unity project manifest. + * @param projectPath The path to the projects root directory * @param data The manifest to save */ export const saveProjectManifest = function ( - workingDirectory: string, + projectPath: string, data: UnityProjectManifest ) { - const manifestPath = manifestPathFor(workingDirectory); + const manifestPath = manifestPathFor(projectPath); const json = JSON.stringify(data, null, 2); try { fse.ensureDirSync(path.dirname(manifestPath));