Skip to content

Commit

Permalink
Fix prettier and vscode-ext on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pomber committed Feb 16, 2019
1 parent d9cd82e commit 9e2af5d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 44 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
89 changes: 47 additions & 42 deletions vscode-ext/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"<script>window._CLI=null</script>",
`<script>/*<!--*/window._CLI={commits:${JSON.stringify(
commits
)},path:'${currentPath}'}/*-->*/</script>`
)
.replace(
"<head>",
`<head><base href="${vscode.Uri.file(
path.join(context.extensionPath, "site")
).with({
scheme: "vscode-resource"
})}/"/>`
);
getCommits(currentPath)
.then(commits => {
const newIndex = index
.replace(
"<script>window._CLI=null</script>",
`<script>/*<!--*/window._CLI={commits:${JSON.stringify(
commits
)},path:'${currentPath}'}/*-->*/</script>`
)
.replace(
"<head>",
`<head><base href="${vscode.Uri.file(
path.join(context.extensionPath, "site")
).with({
scheme: "vscode-resource"
})}/"/>`
);

panel.webview.html = newIndex;
})
.catch(console.error);
panel.webview.html = newIndex;
})
.catch(console.error);
} catch (e) {
console.error(e);
throw e;
}
}
);

Expand Down

0 comments on commit 9e2af5d

Please sign in to comment.