Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:estruyf/vscode-front-matter into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Aug 22, 2023
2 parents 5435a6c + dc5a48e commit faf8e66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions src/helpers/CustomScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}'`;
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit faf8e66

Please sign in to comment.