Fix preview error on large files

Signed-off-by: trivernis <trivernis@protonmail.com>
main
trivernis 3 years ago
parent 46aa2c2ed5
commit 15df4b90f4
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

9
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "snekdown-preview", "name": "snekdown",
"version": "0.0.1", "version": "0.9.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -75,11 +75,6 @@
} }
} }
}, },
"@microsoft/vscode-file-downloader-api": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@microsoft/vscode-file-downloader-api/-/vscode-file-downloader-api-1.0.1.tgz",
"integrity": "sha512-cO9n/IpTMbXizz5YcEkiuRyX5r66SBY/3LnrlroyXbQXrgDdaKecfV3n4viTcvp9O//QF2AxcBfDZex2d4VSTg=="
},
"@nodelib/fs.scandir": { "@nodelib/fs.scandir": {
"version": "2.1.4", "version": "2.1.4",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz",

@ -13,7 +13,7 @@
"url": "https://github.com/Trivernis/snekdown-vscode-extension.git" "url": "https://github.com/Trivernis/snekdown-vscode-extension.git"
}, },
"description": "Preview and commands for the snekdown markdown flavour", "description": "Preview and commands for the snekdown markdown flavour",
"version": "0.9.0", "version": "0.9.1",
"engines": { "engines": {
"vscode": "^1.52.0" "vscode": "^1.52.0"
}, },
@ -76,16 +76,20 @@
} }
] ]
}, },
"languages": [{ "languages": [
"id": "snekdown", {
"aliases": ["Snekdown"], "id": "snekdown",
"extensions": [ "aliases": [
".sd.md", "Snekdown"
".snekdown", ],
".sd", "extensions": [
".sdown" ".sd.md",
] ".snekdown",
}], ".sd",
".sdown"
]
}
],
"grammars": [ "grammars": [
{ {
"language": "snekdown", "language": "snekdown",
@ -113,6 +117,7 @@
"eslint": "^7.15.0", "eslint": "^7.15.0",
"@typescript-eslint/eslint-plugin": "^4.9.0", "@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0", "@typescript-eslint/parser": "^4.9.0",
"@types/node-fetch": "^2.5.8",
"glob": "^7.1.6", "glob": "^7.1.6",
"mocha": "^8.1.3", "mocha": "^8.1.3",
"typescript": "^4.1.2", "typescript": "^4.1.2",
@ -122,11 +127,6 @@
"webpack-cli": "^4.2.0" "webpack-cli": "^4.2.0"
}, },
"dependencies": { "dependencies": {
"@microsoft/vscode-file-downloader-api": "^1.0.1",
"@types/node-fetch": "^2.5.8",
"node-fetch": "^2.6.1" "node-fetch": "^2.6.1"
}, }
"extensionDependencies": [
"mindaro-dev.file-downloader"
]
} }

@ -1,5 +1,4 @@
import {getApi, FileDownloader} from "@microsoft/vscode-file-downloader-api"; import { exec, execFile, spawn } from "child_process";
import { exec, execFile } from "child_process";
import { chmodSync } from "fs"; import { chmodSync } from "fs";
import * as os from "os"; import * as os from "os";
import * as path from "path"; import * as path from "path";
@ -70,7 +69,6 @@ export class SnekdownWrapper {
* Detects or downloads the snekdown executable * Detects or downloads the snekdown executable
*/ */
public async download () { public async download () {
const fileDownloader: FileDownloader = await getApi();
let execPath: string; let execPath: string;
@ -117,16 +115,21 @@ export class SnekdownWrapper {
cwd = vscode.workspace.workspaceFolders[0].uri.fsPath; cwd = vscode.workspace.workspaceFolders[0].uri.fsPath;
} }
return new Promise((res, rej) => { return new Promise((res, rej) => {
let process = execFile(this.executable, [command, ...args], {cwd}, (err, stdout, stderr) => { let child = spawn(this.executable, [command, ...args], {cwd});
if (err) { let stdout = "";
rej(err); child.stdout.on("data", data => {
stdout += data as string;
});
child.stderr.on("data", data => {
console.log("Snekdown: ", "" + data as string);
});
child.on("exit", code => {
if (code != 0) {
rej(new Error("Failed to execute command. Open the developer console for more information."))
} else {
res(stdout)
} }
if (process.exitCode !== 0) { });
rej(stderr);
}
console.log(stderr);
res(stdout);
});
}); });
} }
} }

Loading…
Cancel
Save