chore: changelog preview should be ok.

This commit is contained in:
octod 2017-09-08 10:16:16 +02:00
parent 40fbd7bacb
commit 0b42ddfe75
4 changed files with 29 additions and 9 deletions

View file

@ -18,8 +18,7 @@
"Yellow": "#FFA000" "Yellow": "#FFA000"
}, },
"changelog": { "changelog": {
"lastversion": "", "lastversion": "1.0.2"
"stopShowingChangelog": false
}, },
"icons": { "icons": {
"theme": { "theme": {

View file

@ -1,8 +1,15 @@
import * as path from 'path'; import * as path from 'path';
import * as vscode from 'vscode';
import { getDefaultValues, getPackageJSON, writeFile } from "./fs"; 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 } { function splitVersion(input: string): { major: number, minor: number, patch: number } {
let [ major, minor, patch ] = input.split('.').map(i => parseInt(i)); 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 { 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 { export function shouldShowChangelog(): boolean {
@ -20,20 +43,19 @@ export function shouldShowChangelog(): boolean {
if (defaults.changelog == undefined || (defaults.changelog !== undefined && typeof defaults.changelog.lastversion !== 'string')) { if (defaults.changelog == undefined || (defaults.changelog !== undefined && typeof defaults.changelog.lastversion !== 'string')) {
defaults.changelog = { defaults.changelog = {
lastversion: packageJSON.version, lastversion: packageJSON.version
stopShowingChangelog: false
} }
out = true; out = true;
} else { } else {
let versionCurrent = splitVersion(packageJSON.version); let versionCurrent = splitVersion(packageJSON.version);
let versionOld = splitVersion(defaults.changelog.lastversion); 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; 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; return out;
} }

View file

@ -14,7 +14,6 @@ export interface IAccents {
export interface IChangelog { export interface IChangelog {
lastversion: string; lastversion: string;
stopShowingChangelog: boolean;
} }
export interface IDefaultsThemeIcons { export interface IDefaultsThemeIcons {

File diff suppressed because one or more lines are too long