Skip to content

Commit

Permalink
Merge pull request #53 from asuthy/keep-newline
Browse files Browse the repository at this point in the history
Add support for --keep-newline
  • Loading branch information
bradymholt authored Nov 2, 2023
2 parents 422c723 + f9e09a6 commit 8d9be68
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ function buildCommandArguments(options) {
if (options.wrapComment) {
commandArgs += " --wrap-comment";
}
if (options.keepNewline) {
commandArgs += " --keep-newline";
}
return commandArgs;
}
exports.buildCommandArguments = buildCommandArguments;
4 changes: 4 additions & 0 deletions dist/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export interface IOptions {
* Do not add an extra empty line at end of the output
*/
noExtraLine?: boolean;
/**
* Preserve empty line in plpgsql code
*/
keepNewline?: boolean;
/**
* Maximum length of a query; the line will be cut before or at the given length
*/
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,9 @@ export function buildCommandArguments(options: IOptions) {
commandArgs += " --wrap-comment";
}

if (options.keepNewline) {
commandArgs += " --keep-newline";
}

return commandArgs;
}
5 changes: 5 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export interface IOptions {
*/
noExtraLine?: boolean;

/**
* Preserve empty line in plpgsql code
*/
keepNewline?: boolean;

/**
* Maximum length of a query; the line will be cut before or at the given length
*/
Expand Down
4 changes: 4 additions & 0 deletions test/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@ describe("options", function () {
expect(buildCommand({ pgFormatterPath: "/usr/bin/custom" })).contain("/usr/bin/custom");
expect(buildCommand({ pgFormatterPath: "/usr/bin/custom" })).to.not.contain("pg_format");
});

it("keepNewline", function () {
expect(buildCommandArguments({ keepNewline: true })).to.contain("--keep-newline");
});
});

0 comments on commit 8d9be68

Please sign in to comment.