#628 - Fix path and data argument

This commit is contained in:
Elio Struyf
2023-08-22 11:52:00 +02:00
parent 0b722e3dba
commit dc5a48ea89
2 changed files with 13 additions and 2 deletions
+2
View File
@@ -12,6 +12,8 @@
### 🐞 Fixes
- [#628](https://github.com/estruyf/vscode-front-matter/issues/628): Fix path argument and JSON data on custom scripts
## [9.0.0] - 2023-08-21 - [Release notes](https://beta.frontmatter.codes/updates/v9.0.0)
### 🌎 Multilingual support
+11 -2
View File
@@ -222,7 +222,12 @@ export class CustomScript {
let articleData = '';
if (os.type() === 'Windows_NT') {
const jsonData = JSON.stringify(article?.data);
articleData = `'${jsonData.replace(/"/g, `\"`)}'`;
if (script.command && script.command.toLowerCase() === "powershell") {
articleData = `'${jsonData.replace(/"/g, `\\"`)}'`;
} else {
articleData = `"${jsonData.replace(/"/g, `\\"`)}"`;
}
} else {
articleData = JSON.stringify(article?.data).replace(/'/g, '%27');
articleData = `'${articleData}'`;
@@ -360,7 +365,11 @@ export class CustomScript {
return;
}
const fullScript = `${command} ${scriptPath} ${args}`;
if (osType === 'Windows_NT' && command.toLowerCase() === "powershell") {
command = `${command} -File`;
}
const fullScript = `${command} "${scriptPath}" ${args}`;
Logger.info(`Executing: ${fullScript}`);
exec(fullScript, { cwd: wsPath }, (error, stdout) => {