chore: changelog preview should be ok.
This commit is contained in:
parent
40fbd7bacb
commit
0b42ddfe75
4 changed files with 29 additions and 9 deletions
|
@ -18,8 +18,7 @@
|
|||
"Yellow": "#FFA000"
|
||||
},
|
||||
"changelog": {
|
||||
"lastversion": "",
|
||||
"stopShowingChangelog": false
|
||||
"lastversion": "1.0.2"
|
||||
},
|
||||
"icons": {
|
||||
"theme": {
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { getDefaultValues, getPackageJSON, writeFile } from "./fs";
|
||||
import { PATHS } from "../consts/paths";
|
||||
import { PATHS } from '../consts/paths';
|
||||
|
||||
function previewFile(): void {
|
||||
let uri = vscode.Uri.parse(path.join('file:///', PATHS.VSIX_DIR, './CHANGELOG.md'));
|
||||
|
||||
vscode.commands.executeCommand('markdown.showPreview', uri);
|
||||
|
||||
}
|
||||
|
||||
function splitVersion(input: string): { major: number, minor: number, patch: number } {
|
||||
let [ major, minor, patch ] = input.split('.').map(i => parseInt(i));
|
||||
|
@ -10,7 +17,23 @@ function splitVersion(input: string): { major: number, minor: number, patch: num
|
|||
}
|
||||
|
||||
export function showChangelog(): void {
|
||||
let extname: string = 'Microsoft.vscode-markdown';
|
||||
let md = vscode.extensions.getExtension<any>(extname);
|
||||
|
||||
if (md === undefined) {
|
||||
console.warn(`Ext not found ${ extname }`)
|
||||
return;
|
||||
}
|
||||
|
||||
if (md.isActive) {
|
||||
previewFile();
|
||||
} else {
|
||||
md.activate().then(() => {
|
||||
previewFile();
|
||||
}, reason => {
|
||||
console.warn(reason);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldShowChangelog(): boolean {
|
||||
|
@ -20,20 +43,19 @@ export function shouldShowChangelog(): boolean {
|
|||
|
||||
if (defaults.changelog == undefined || (defaults.changelog !== undefined && typeof defaults.changelog.lastversion !== 'string')) {
|
||||
defaults.changelog = {
|
||||
lastversion: packageJSON.version,
|
||||
stopShowingChangelog: false
|
||||
lastversion: packageJSON.version
|
||||
}
|
||||
out = true;
|
||||
} else {
|
||||
let versionCurrent = splitVersion(packageJSON.version);
|
||||
let versionOld = splitVersion(defaults.changelog.lastversion);
|
||||
|
||||
out = versionCurrent.major !== versionOld.major || versionCurrent.minor !== versionOld.minor || versionCurrent.patch !== versionOld.patch;
|
||||
out = versionCurrent.major > versionOld.major || versionCurrent.minor > versionOld.minor || versionCurrent.patch > versionOld.patch;
|
||||
|
||||
defaults.changelog.lastversion = packageJSON.version;
|
||||
}
|
||||
|
||||
writeFile(path.join(PATHS.VSIX_DIR, './extensions/defaults.json'), JSON.stringify(defaults, null, 2));
|
||||
writeFile(path.join('./extensions/defaults.json'), JSON.stringify(defaults, null, 2));
|
||||
|
||||
return out;
|
||||
}
|
|
@ -14,7 +14,6 @@ export interface IAccents {
|
|||
|
||||
export interface IChangelog {
|
||||
lastversion: string;
|
||||
stopShowingChangelog: boolean;
|
||||
}
|
||||
|
||||
export interface IDefaultsThemeIcons {
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue