From b44b37456e26cad2cf7261d6b6c3e7365c16d2cd Mon Sep 17 00:00:00 2001 From: Alex <apuret@takima.fr> Date: Wed, 8 Dec 2021 16:28:45 +0100 Subject: [PATCH] fix: marked module not include in bundle --- .../src/view/briefingView.ts | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/deadlock-plugins/deadlock-extension/src/view/briefingView.ts b/deadlock-plugins/deadlock-extension/src/view/briefingView.ts index 589323eb..827e56b3 100644 --- a/deadlock-plugins/deadlock-extension/src/view/briefingView.ts +++ b/deadlock-plugins/deadlock-extension/src/view/briefingView.ts @@ -1,20 +1,21 @@ -import View from "./view"; +import View from './view'; -import * as vscode from "vscode"; +import * as vscode from 'vscode'; + +import { marked } from 'marked'; +import * as path from 'path'; // eslint-disable-next-line @typescript-eslint/no-var-requires -const marked = require("marked"); -const fs = require("fs"); -import * as path from "path"; +const fs = require('fs'); -import { DOCS_PATH, BRIEFING_FILE_NAME } from "../core/config"; -import { WebviewBase } from "./webviewBase"; -import { OPEN_BRIEFING_COMMAND } from "../theia/command"; +import { DOCS_PATH, BRIEFING_FILE_NAME } from '../core/config'; +import { WebviewBase } from './webviewBase'; +import { OPEN_BRIEFING_COMMAND } from '../theia/command'; -import { userConfig } from "../extension"; -import { setInterval } from "timers"; +import { userConfig } from '../extension'; +import { setInterval } from 'timers'; -export const BRIEFING_ID = "brefingView"; +export const BRIEFING_ID = 'brefingView'; export default class BriefingView extends WebviewBase { private briefingContent: string | undefined; @@ -23,12 +24,12 @@ export default class BriefingView extends WebviewBase { private loadingBriefing: boolean = false; constructor() { - super(BRIEFING_ID, "Briefing", OPEN_BRIEFING_COMMAND); + super(BRIEFING_ID, 'Briefing', OPEN_BRIEFING_COMMAND); } toBase64(file: string) { const result = fs.readFileSync(path.join(DOCS_PATH, file), { - encoding: "base64", + encoding: 'base64', }); return result; } @@ -37,8 +38,8 @@ export default class BriefingView extends WebviewBase { const imageRegex = /\!\[(.*?)\]\(\b(image:)(.*?\))?/g return text.replace(imageRegex, (match, title, imagePrefix, img) => { - const fileName = img.replace(")", ""); - const extension = fileName.split("\."); + const fileName = img.replace(')', ''); + const extension = fileName.split('.'); return `); } catch (e) { console.error(e); - this.briefingContent = "Error while parsing your briefing." + this.briefingContent = 'Error while parsing your briefing.' } this.show(); }, (error) => { - console.error("Cannot load briefing", error); + console.error('Cannot load briefing', error); this.errorLoadingBriefing = true; } ); @@ -76,7 +77,7 @@ export default class BriefingView extends WebviewBase { } render() { - let output = ""; + let output = ''; if (userConfig.isProfessor()) { output += ` @@ -94,32 +95,32 @@ export default class BriefingView extends WebviewBase { if (this.briefingContent) { output += `<h1>Mission Goal 🕶</h1>${marked(this.briefingContent)}`; } else if (this.errorLoadingBriefing) { - output += "Cannot load briefing."; + output += 'Cannot load briefing.'; } else { - output += "Loading briefing.."; + output += 'Loading briefing..'; } - output += "<br/>"; + output += '<br/>'; if (userConfig.getUsername()) { output += this.renderUserChallengeConfig(); } else { - output += "Loading help.."; + output += 'Loading help..'; } return output; } private renderUserChallengeConfig() { - let adresses = ""; + let adresses = ''; let pathsLength = 0; const paths = userConfig.getPaths(); for (const key in paths) { - if (key !== "3000") { + if (key !== '3000') { pathsLength++; const path = paths[key]; - if (userConfig.getHost() === "localhost") { + if (userConfig.getHost() === 'localhost') { adresses += `<li>${key} binded on <a href="http://${userConfig.getHost()}:${path}">${path}</a></li>`; } else { adresses += `<li>${key} binded on <a href="https://${userConfig.getHost()}/${path}/">${path}</a></li>`; @@ -131,6 +132,6 @@ export default class BriefingView extends WebviewBase { return `<h3>Configuration</h3>You have the following adresses availables for your challenge : <ul>${adresses}</ul>`; } - return ""; + return ''; } } -- GitLab