Skip to content

Commit

Permalink
refactor: rename function params (#101)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ComradeVanti authored Jan 14, 2024
1 parent 1bba178 commit 6fe0806
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/types/project-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
16 changes: 8 additions & 8 deletions src/utils/project-manifest-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down

0 comments on commit 6fe0806

Please sign in to comment.