From 9e2af5d2379799a5072e77d3fd72b691cf5a2492 Mon Sep 17 00:00:00 2001 From: pomber Date: Fri, 15 Feb 2019 22:24:05 -0300 Subject: [PATCH] Fix prettier and vscode-ext on windows --- package.json | 4 +- vscode-ext/extension.js | 89 ++++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index b525a5c..75b6726 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "scripts": { "start": "react-scripts start", "build": "react-scripts build", - "format": "prettier --write '**/*.{js,jsx,md,json,html,css,yml}' --ignore-path .gitignore", - "test-prettier": "prettier --check '**/*.{js,jsx,md,json,html,css,yml}' --ignore-path .gitignore", + "format": "prettier --write \"**/*.{js,jsx,md,json,html,css,yml}\" --ignore-path .gitignore", + "test-prettier": "prettier --check \"**/*.{js,jsx,md,json,html,css,yml}\" --ignore-path .gitignore", "test-cra": "react-scripts test", "test": "run-s test-prettier test-cra", "eject": "react-scripts eject" diff --git a/vscode-ext/extension.js b/vscode-ext/extension.js index 13a55eb..24a0797 100644 --- a/vscode-ext/extension.js +++ b/vscode-ext/extension.js @@ -17,53 +17,58 @@ function activate(context) { "extension.git-file-history", function() { // The code you place here will be executed every time your command is executed - - const currentPath = getCurrentPath(); - if (!currentPath) { - vscode.window.showInformationMessage("No active file"); - return; - } - - const panel = vscode.window.createWebviewPanel( - "gfh", - `${path.basename(currentPath)} (Git History)`, - vscode.ViewColumn.One, - { - enableScripts: true, - retainContextWhenHidden: true, - localResourceRoots: [ - vscode.Uri.file(path.join(context.extensionPath, "site")) - ] + try { + const currentPath = getCurrentPath(); + if (!currentPath) { + vscode.window.showInformationMessage("No active file"); + return; } - ); - const indexFile = vscode.Uri.file( - path.join(context.extensionPath, "site", "index.html") - ); + const panel = vscode.window.createWebviewPanel( + "gfh", + `${path.basename(currentPath)} (Git History)`, + vscode.ViewColumn.One, + { + enableScripts: true, + retainContextWhenHidden: true, + localResourceRoots: [ + vscode.Uri.file(path.join(context.extensionPath, "site")) + ] + } + ); + const indexPath = path.join( + context.extensionPath, + "site", + "index.html" + ); - const index = fs.readFileSync(indexFile.path, "utf-8"); + const index = fs.readFileSync(indexPath, "utf-8"); - getCommits(currentPath) - .then(commits => { - const newIndex = index - .replace( - "", - `` - ) - .replace( - "", - `` - ); + getCommits(currentPath) + .then(commits => { + const newIndex = index + .replace( + "", + `` + ) + .replace( + "", + `` + ); - panel.webview.html = newIndex; - }) - .catch(console.error); + panel.webview.html = newIndex; + }) + .catch(console.error); + } catch (e) { + console.error(e); + throw e; + } } );