Skip to content

Conversation

thomasmost
Copy link
Contributor

Resolves Issue #132 - Absolute file paths ruin our git diffs

List of changes:

  • Parent filename is scanned for current directory name and trimmed to paths following that (inclusive)
  • If the current directory name is never found we fallback to the full path (can assume that the path starts below current directory or in a different structure altogether)
  • Added a parser test - it should determine the parent fileName relative to the project directory
  • Added a parent.fileName comparison to checkComponent

src/parser.ts Outdated

// We'll use the currentDirectoryName to trim parent fileNames
const currentDirectoryPath = process.cwd();
const currentDirectoryParts = currentDirectoryPath.split('/');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would make sense to use path.sep instead of '/' only (https://nodejs.org/api/path.html#path_path_sep).

src/parser.ts Outdated
const parentName = parent.name.text;
const { fileName } = parent.getSourceFile();

const fileNameParts = fileName.split('/');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably the same as above path.sep

src/parser.ts Outdated
}
let trimmedFileName;
if (trimmedFileNameParts.length) {
trimmedFileName = trimmedFileNameParts.join('/');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and once again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smrt

@pvasek pvasek merged commit 4e9c3e6 into styleguidist:master Oct 7, 2018
@thomasmost thomasmost deleted the tcm-relative-parent-filenames branch October 8, 2018 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants