Skip to content

Commit

Permalink
fix: more renames
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTowles committed Sep 29, 2022
1 parent 82ecf93 commit 1a6fe47
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
-->
</p>

## Requirements

- `xclip` command be required (Linux)
- `powershell` command be required (Win32)
- `pbpaste` command be required (Mac)

<p align="center">
Smart selection with double clicks for VS Code.<br>

</p>
`// TODO GIF`

## Usage
Expand Down
1 change: 0 additions & 1 deletion src/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('Configuration', () => {

it('check parse of default values', async () => {


const config = await parseConfigurationToConfig({
projectRootDirPath: __dirname,
editorOpenFilePath: __filename,
Expand Down
8 changes: 4 additions & 4 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface Configuration {
readonly imageFolderPath: string;


readonly insertPatternConfig: string;
readonly insertPattern: string;
readonly showFilePathConfirmInputBox: boolean,
readonly filePathConfirmInputBoxMode: FilePathConfirmInputBoxModeEnum;
readonly encodePath: EncodePathEnum;
Expand Down Expand Up @@ -51,7 +51,7 @@ export const parseConfigurationToConfig = async ({ projectRootDirPath, editorOpe


let encodePath = configuration.get<EncodePathEnum>(Constants.Config_EncodePath, EncodePathEnum.UrlEncodeSpace);
let insertPatternConfig = configuration.get<string>(Constants.Config_InsertPattern, '');
let insertPattern = configuration.get<string>(Constants.Config_InsertPattern, '');


let imageUriPathPrefix = configuration.get<string>(Constants.Config_ImageUriPathPrefix, '');
Expand All @@ -73,7 +73,7 @@ export const parseConfigurationToConfig = async ({ projectRootDirPath, editorOpe
imageFolderPath = replacePathVariable({ pathStr: imageFolderPath, projectRootDirPath: projectRootDirPath, editorOpenFilePath: editorOpenFilePath });
imageNamePrefix = replacePathVariable({ pathStr: imageNamePrefix, projectRootDirPath: projectRootDirPath, editorOpenFilePath: editorOpenFilePath });
imageNameSuffix = replacePathVariable({ pathStr: imageNameSuffix, projectRootDirPath: projectRootDirPath, editorOpenFilePath: editorOpenFilePath });
insertPatternConfig = replacePathVariable({ pathStr: insertPatternConfig, projectRootDirPath: projectRootDirPath, editorOpenFilePath: editorOpenFilePath });
insertPattern = replacePathVariable({ pathStr: insertPattern, projectRootDirPath: projectRootDirPath, editorOpenFilePath: editorOpenFilePath });


const config: Configuration = {
Expand All @@ -84,7 +84,7 @@ export const parseConfigurationToConfig = async ({ projectRootDirPath, editorOpe

encodePath: encodePath,

insertPatternConfig: insertPatternConfig,
insertPattern: insertPattern,
showFilePathConfirmInputBox: showFilePathConfirmInputBox,
filePathConfirmInputBoxMode: filePathConfirmInputBoxMode,

Expand Down
2 changes: 1 addition & 1 deletion src/folderUtil.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('FolderUtil', () => {
// clean up created folder
let folderStat = await fse.stat(testDir)
if (folderStat.isDirectory()) {
await fse.rmdir(testDir, { recursive: true });
await fse.rm(testDir, { recursive: true });
}
})
});
Expand Down
12 changes: 6 additions & 6 deletions src/renderTextWithImagePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const PATH_VARIABLE_IMAGE_SYNTAX_SUFFIX = /\$\{imageSyntaxSuffix\}/g;

export const renderTextWithImagePath = async ({ languageId, config, imageFilePath, logger }: { languageId: string; config: Configuration; imageFilePath: string; logger: ILogger; }): Promise<string> => {

logger.debug(`renderFilePath start - ${imageFilePath}`);
// logger.debug(`renderFilePath start - ${imageFilePath}`);

imageFilePath = await getRelativePathFromEditorFile({ editorOpenFolderPath: config.editorOpenFolderPath, imageFilePath, logger });
let originalImagePath = imageFilePath;
Expand All @@ -55,13 +55,13 @@ export const renderTextWithImagePath = async ({ languageId, config, imageFilePat
imageSyntaxPrefix = `![](`
imageSyntaxSuffix = `)`
break;
case "asciidoc":
imageSyntaxPrefix = `image::`
imageSyntaxSuffix = `[]`
// todo add html and other image syntax
default:
// do default
break;
}

let result = config.insertPatternConfig
let result = config.insertPattern
result = result.replace(PATH_VARIABLE_IMAGE_SYNTAX_PREFIX, imageSyntaxPrefix);
result = result.replace(PATH_VARIABLE_IMAGE_SYNTAX_SUFFIX, imageSyntaxSuffix);

Expand All @@ -70,7 +70,7 @@ export const renderTextWithImagePath = async ({ languageId, config, imageFilePat
result = result.replace(PATH_VARIABLE_IMAGE_FILE_NAME, fileName);
result = result.replace(PATH_VARIABLE_IMAGE_FILE_NAME_WITHOUT_EXT, fileNameWithoutExt);

logger.debug('renderFilePath end');
// logger.debug('renderFilePath end');
return result;
}

Expand Down

0 comments on commit 1a6fe47

Please sign in to comment.