Skip to content

Commit

Permalink
fix: remove some of the debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTowles committed Sep 26, 2022
1 parent 472c0c6 commit 82ecf93
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 32 deletions.
3 changes: 0 additions & 3 deletions src/configuration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { describe, expect, it } from 'vitest'
import { WorkspaceConfiguration, ConfigurationTarget } from 'vscode';
import { Constants } from "./constants";
import { parseConfigurationToConfig, replacePathVariable } from "./configuration";
import path from 'path';
import { MockWorkspaceConfiguration } from './test/mockWorkspaceConfiguration';




describe('Configuration', () => {
const mockWorkspaceConfiguration = new MockWorkspaceConfiguration({ currentDirectory: __dirname });
it('check mock works', () => {
Expand Down
1 change: 0 additions & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Constants } from "./constants";
import { WorkspaceConfiguration } from 'vscode';
import path from "path";
import { ILogger } from "./logger";
import { ensureFileAndGetItsDirectory } from "./folderUtil";

export interface Configuration {
Expand Down
24 changes: 8 additions & 16 deletions src/paster.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import * as vscode from 'vscode';
import * as path from 'path';
import * as fse from 'fs-extra';
import * as upath from 'upath';
import { ILogger, Logger } from './logger';
import { createImageDirWithImagePath, ensurePngAddedToFileName, makeImagePath } from './folderUtil';
import { linuxCreateImageWithXClip } from './osTools/linux';
import { DateTime } from 'luxon';
import { win32CreateImageWithPowershell } from './osTools/win32';
import { macCreateImageWithAppleScript } from './osTools/macOS';
import { SaveClipboardImageToFileResult } from './dto/SaveClipboardImageToFileResult';
import * as vscode from 'vscode';
import { Configuration, FilePathConfirmInputBoxModeEnum, parseConfigurationToConfig } from './configuration';
import { Constants } from './constants';
import { SaveClipboardImageToFileResult } from './dto/SaveClipboardImageToFileResult';
import { createImageDirWithImagePath, ensurePngAddedToFileName, makeImagePath } from './folderUtil';
import { ILogger } from './logger';
import { linuxCreateImageWithXClip } from './osTools/linux';
import { macCreateImageWithAppleScript } from './osTools/macOS';
import { win32CreateImageWithPowershell } from './osTools/win32';
import { renderTextWithImagePath } from './renderTextWithImagePath';


export class Paster {




public static async paste(logger: ILogger): Promise<void> {
// get current edit file path
let textEditor = vscode.window.activeTextEditor;
Expand Down Expand Up @@ -51,7 +46,7 @@ export class Paster {
return;
}

// load other config
// load config
let config: Configuration;
try {

Expand All @@ -68,7 +63,6 @@ export class Paster {
}

// replace variable in config

const imagePath = await this.getImagePath({ editorOpenFilePath, selectText, config: config, logger })
try {
// is the file existed?
Expand All @@ -86,7 +80,6 @@ export class Paster {
return;
}


logger.debug('Paste End');
}

Expand Down Expand Up @@ -173,7 +166,6 @@ export class Paster {
} else {
filePathOrName = userEnteredFileName
}

}

} else {
Expand Down
3 changes: 1 addition & 2 deletions src/renderTextWithImagePath.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { describe, expect, it } from 'vitest'
import * as path from 'path';
import util from 'util';
import { encodeImagePath, getRelativePathFromEditorFile, renderTextWithImagePath } from './renderTextWithImagePath';
import { MockWorkspaceConfiguration } from './test/mockWorkspaceConfiguration';
import { Configuration, EncodePathEnum, parseConfigurationToConfig } from './configuration';
import { MockLogger } from './test/mockLogger';
import { config } from 'process';



const createMockConfig = async ({ projectRootDirPath, editorOpenFilePath }: { projectRootDirPath: string, editorOpenFilePath: string }): Promise<Configuration> => {
Expand Down
12 changes: 2 additions & 10 deletions src/renderTextWithImagePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import * as upath from 'upath';
import { ILogger } from './logger';
import { ensurePathIsDirectory } from "./folderUtil";




/**
* render the image file path dependent on file type
* e.g. in markdown image file path will render to ![](path)
Expand All @@ -18,17 +15,13 @@ export const getRelativePathFromEditorFile = async ({ editorOpenFolderPath, imag

await ensurePathIsDirectory(editorOpenFolderPath);

logger.debug(`imageFilePath = ${imageFilePath}`);
imageFilePath = path.relative(editorOpenFolderPath, imageFilePath);

logger.debug(`imageFilePath after relative = ${imageFilePath}`);

// Normalize a string path, reducing '..' and '.' parts. When multiple slashes are
// found, they're replaced by a single one; when the path contains a trailing slash, it
// is preserved. On Windows backslashes are used.
imageFilePath = upath.normalize(imageFilePath);
logger.debug(`imageFilePath after normalize = ${imageFilePath}`);


return imageFilePath;
}

Expand All @@ -45,14 +38,13 @@ export const renderTextWithImagePath = async ({ languageId, config, imageFilePat

imageFilePath = await getRelativePathFromEditorFile({ editorOpenFolderPath: config.editorOpenFolderPath, imageFilePath, logger });
let originalImagePath = imageFilePath;
logger.debug(`renderFilePath after getRelativePathFromEditorFile - ${imageFilePath}`);

let ext = path.extname(originalImagePath);
let fileName = path.basename(originalImagePath);
let fileNameWithoutExt = path.basename(originalImagePath, ext);

imageFilePath = `${config.imageUriPathPrefix}${imageFilePath}${config.imageUriPathSuffix}`;

logger.debug(`imageFilePath Uri Pre & Suf = ${imageFilePath}`);

imageFilePath = encodeImagePath({ imageFilePath, encodePath: config.encodePath });

Expand Down

0 comments on commit 82ecf93

Please sign in to comment.