mirror of
https://github.com/pomber/git-history.git
synced 2024-09-11 14:35:57 +03:00
Fix prettier and vscode-ext on windows
This commit is contained in:
parent
d9cd82e8de
commit
9e2af5d237
@ -17,8 +17,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"format": "prettier --write '**/*.{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-prettier": "prettier --check \"**/*.{js,jsx,md,json,html,css,yml}\" --ignore-path .gitignore",
|
||||||
"test-cra": "react-scripts test",
|
"test-cra": "react-scripts test",
|
||||||
"test": "run-s test-prettier test-cra",
|
"test": "run-s test-prettier test-cra",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
|
@ -17,53 +17,58 @@ function activate(context) {
|
|||||||
"extension.git-file-history",
|
"extension.git-file-history",
|
||||||
function() {
|
function() {
|
||||||
// The code you place here will be executed every time your command is executed
|
// The code you place here will be executed every time your command is executed
|
||||||
|
try {
|
||||||
const currentPath = getCurrentPath();
|
const currentPath = getCurrentPath();
|
||||||
if (!currentPath) {
|
if (!currentPath) {
|
||||||
vscode.window.showInformationMessage("No active file");
|
vscode.window.showInformationMessage("No active file");
|
||||||
return;
|
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"))
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
const indexFile = vscode.Uri.file(
|
const panel = vscode.window.createWebviewPanel(
|
||||||
path.join(context.extensionPath, "site", "index.html")
|
"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)
|
getCommits(currentPath)
|
||||||
.then(commits => {
|
.then(commits => {
|
||||||
const newIndex = index
|
const newIndex = index
|
||||||
.replace(
|
.replace(
|
||||||
"<script>window._CLI=null</script>",
|
"<script>window._CLI=null</script>",
|
||||||
`<script>/*<!--*/window._CLI={commits:${JSON.stringify(
|
`<script>/*<!--*/window._CLI={commits:${JSON.stringify(
|
||||||
commits
|
commits
|
||||||
)},path:'${currentPath}'}/*-->*/</script>`
|
)},path:'${currentPath}'}/*-->*/</script>`
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"<head>",
|
"<head>",
|
||||||
`<head><base href="${vscode.Uri.file(
|
`<head><base href="${vscode.Uri.file(
|
||||||
path.join(context.extensionPath, "site")
|
path.join(context.extensionPath, "site")
|
||||||
).with({
|
).with({
|
||||||
scheme: "vscode-resource"
|
scheme: "vscode-resource"
|
||||||
})}/"/>`
|
})}/"/>`
|
||||||
);
|
);
|
||||||
|
|
||||||
panel.webview.html = newIndex;
|
panel.webview.html = newIndex;
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user