Skip to content

Commit

Permalink
Formatter fix (#5)
Browse files Browse the repository at this point in the history
Adds the stdin-filename option to the executable when document exists. Alters the command arguments settings description to reflect the default options changes. Fixes #4.

---------

Co-authored-by: Eugene “Aeron” Glybin <[email protected]>
  • Loading branch information
guillaumealgis and Aeron authored Aug 27, 2023
1 parent c5a18e6 commit 2e49125
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions Scripts/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ class Formatter {
this.config = config;
}

async getProcess() {
async getProcess(filename = null) {
const executablePath = nova.path.expanduser(this.config.get("executablePath"));
const commandArguments = this.config.get("commandArguments");
const defaultOptions = ["--quiet", "-"];
const defaultOptions = (filename)
? ["--quiet", `--stdin-filename=${filename}`, "-"]
: ["--quiet", "-"];

if (!nova.fs.stat(executablePath)) {
console.error(`Executable ${executablePath} does not exist`);
Expand Down Expand Up @@ -49,7 +51,9 @@ class Formatter {
return;
}

let process = await this.getProcess();
let process = await this.getProcess(
editor.document.path ? nova.path.basename(editor.document.path) : null
);

if (!process) {
if (reject) reject("no process");
Expand Down
4 changes: 2 additions & 2 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
"key": "cc.aeron.nova-black.commandArguments",
"title": "Command Arguments",
"description": "Additional arguments. The --quiet option always set.",
"description": "Additional arguments. The --quiet option is always set. The --stdin-filename is set conditionally.",
"type": "string",
"default": null
},
Expand All @@ -61,7 +61,7 @@
{
"key": "cc.aeron.nova-black.commandArguments",
"title": "Command Arguments",
"description": "Additional arguments. The --quiet option always set.",
"description": "Additional arguments. The --quiet option is always set. The --stdin-filename is set conditionally.",
"type": "string"
},
{
Expand Down

0 comments on commit 2e49125

Please sign in to comment.