Adds new ${directory} token

Changes ${path} token to be the full path
Adds relative formatting support
This commit is contained in:
Eric Amodio
2017-09-26 18:19:33 -04:00
parent c44e4c6968
commit 4d18bf708d
6 changed files with 499 additions and 453 deletions

View File

@@ -6,7 +6,10 @@ import { GitStatusFile, IGitStatusFile, IGitStatusFileWithCommit } from '../mode
import * as path from 'path';
export interface IStatusFormatOptions extends IFormatOptions {
relativePath?: string;
tokenOptions?: {
directory?: Strings.ITokenOptions;
file?: Strings.ITokenOptions;
filePath?: Strings.ITokenOptions;
path?: Strings.ITokenOptions;
@@ -15,18 +18,23 @@ export interface IStatusFormatOptions extends IFormatOptions {
export class StatusFileFormatter extends Formatter<IGitStatusFile, IStatusFormatOptions> {
get directory() {
const directory = GitStatusFile.getFormattedDirectory(this._item, false, this._options.relativePath);
return this._padOrTruncate(directory, this._options.tokenOptions!.file);
}
get file() {
const file = path.basename(this._item.fileName);
return this._padOrTruncate(file, this._options.tokenOptions!.file);
}
get filePath() {
const filePath = GitStatusFile.getFormattedPath(this._item);
const filePath = GitStatusFile.getFormattedPath(this._item, undefined, this._options.relativePath);
return this._padOrTruncate(filePath, this._options.tokenOptions!.filePath);
}
get path() {
const directory = GitStatusFile.getFormattedDirectory(this._item, false);
const directory = GitStatusFile.getRelativePath(this._item, this._options.relativePath);
return this._padOrTruncate(directory, this._options.tokenOptions!.file);
}