Skip to content

Commit

Permalink
Version 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymholt committed Apr 4, 2023
1 parent 78c96b3 commit cefbd4c
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 53 deletions.
2 changes: 1 addition & 1 deletion dist/cli.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare function exec(args: any, log?: (text: string) => void): void;
declare const _default: {
exec: typeof exec;
exec: typeof exec;
};
export default _default;
42 changes: 23 additions & 19 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,74 @@ By default, output is written to stdout. (use --write option to edit files in-pl
.options({
write: {
type: "boolean",
describe: "Edit files in-place. (Beware!)"
describe: "Edit files in-place. (Beware!)",
},
spaces: {
type: "number",
default: 4,
describe: "Number of spaces to indent the code"
describe: "Number of spaces to indent the code",
},
tabs: {
type: "boolean",
describe: "Use tabs instead of spaces (spaces option is ignored)"
describe: "Use tabs instead of spaces (spaces option is ignored)",
},
maxLength: {
type: "number",
describe: "Maximum length of a query"
describe: "Maximum length of a query",
},
commaStart: {
type: "boolean",
describe: "Use preceding comma in parameter list"
describe: "Use preceding comma in parameter list",
},
commaBreak: {
type: "boolean",
describe: "In insert statement, add a newline after each comma"
describe: "In insert statement, add a newline after each comma",
},
commaEnd: {
type: "boolean",
default: true,
describe: "Use trailing comma in parameter list"
describe: "Use trailing comma in parameter list",
},
noComment: {
type: "boolean",
describe: "Remove any comments"
describe: "Remove any comments",
},
functionCase: {
type: "string",
default: "unchanged",
choices: ["unchanged", "lowercase", "uppercase", "capitalize"],
describe: "Case of the function names"
describe: "Case of the function names",
},
noGrouping: {
type: "boolean",
default: false,
describe: "Add a newline between statements in transaction regroupement"
describe: "Add a newline between statements in transaction regroupement",
},
keywordCase: {
type: "string",
default: "uppercase",
choices: ["unchanged", "lowercase", "uppercase", "capitalize"],
describe: "Case of the reserved keywords"
describe: "Case of the reserved keywords",
},
formatType: {
type: "boolean",
describe: "Use another formatting type for some statements"
describe: "Use another formatting type for some statements",
},
wrapLimit: {
type: "number",
describe: "Wrap queries at a certain length"
describe: "Wrap queries at a certain length",
},
placeholder: {
type: "string",
describe: "Regex to find code that must not be changed"
describe: "Regex to find code that must not be changed",
},
extraFunction: {
type: "string",
describe: "Path to file containing a list of function names"
describe: "Path to file containing a list of function names",
},
noSpaceFunction: {
type: "boolean",
describe: "Remove the space character between a function call and the open parenthesis that follow",
},
configFile: {
type: "string",
Expand All @@ -85,12 +89,12 @@ By default, output is written to stdout. (use --write option to edit files in-pl
perlBinPath: {
type: "string",
default: "perl",
describe: "The path to the perl executable"
describe: "The path to the perl executable",
},
pgFormatterPath: {
type: "string",
describe: "Path to a custom pg_format version"
}
describe: "Path to a custom pg_format version",
},
})
.demandCommand(1, "").argv;
const filesOrGlobs = parsedArguments._;
Expand All @@ -109,5 +113,5 @@ By default, output is written to stdout. (use --write option to edit files in-pl
}
}
exports.default = {
exec
exec,
};
7 changes: 1 addition & 6 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import { IOptions } from "./options";
* @param fileOrGlob The file path or glob to use (i.e. /tmp/query.sql or *.sql)
* @param options
*/
export declare function formatFiles(
filesOrGlobs: string | string[],
editInPlace: boolean,
options?: IOptions,
log?: (text: string) => void
): string;
export declare function formatFiles(filesOrGlobs: string | string[], editInPlace: boolean, options?: IOptions, log?: (text: string) => void): string;
/**
* Format SQL
* @param sqlText The SQL to be formatted
Expand Down
7 changes: 5 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function formatFiles(filesOrGlobs, editInPlace, options = {}, log = console.log)
let command = `${buildCommand(options)} ${path}`;
// Run pgFormatter
let output = child_process_1.execSync(command, {
encoding: "utf8"
encoding: "utf8",
});
const elapsedTimeMs = Math.round(process.hrtime(startTime)[1] / 1000000);
formatted += output;
Expand All @@ -41,7 +41,7 @@ function formatSql(sqlText, options = {}) {
// Pass sqlText in as stdin and run pgFormatter
let formatted = child_process_1.execSync(command, {
encoding: "utf8",
input: sqlText
input: sqlText,
});
return formatted;
}
Expand Down Expand Up @@ -98,6 +98,9 @@ function buildCommandArguments(options) {
if (options.extraFunction != null) {
commandArgs += ` --extra-function '${options.extraFunction}'`;
}
if (options.noSpaceFunction) {
commandArgs += " --no-space-function";
}
if (options.configFile != null) {
commandArgs += ` --config '${options.configFile}'`;
}
Expand Down
45 changes: 23 additions & 22 deletions dist/options.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
export interface IOptions {
write?: boolean;
spaces?: number;
tabs?: boolean;
maxLength?: number;
commaStart?: boolean;
commaBreak?: boolean;
commaEnd?: boolean;
noComment?: boolean;
functionCase?: CaseOptionEnum;
noGrouping?: boolean;
keywordCase?: CaseOptionEnum;
formatType?: boolean;
wrapLimit?: number;
placeholder?: string;
extraFunction?: string;
configFile?: string;
perlBinPath?: string;
pgFormatterPath?: string;
write?: boolean;
spaces?: number;
tabs?: boolean;
maxLength?: number;
commaStart?: boolean;
commaBreak?: boolean;
commaEnd?: boolean;
noComment?: boolean;
functionCase?: CaseOptionEnum;
noGrouping?: boolean;
keywordCase?: CaseOptionEnum;
formatType?: boolean;
wrapLimit?: number;
placeholder?: string;
extraFunction?: string;
configFile?: string;
noSpaceFunction?: boolean;
perlBinPath?: string;
pgFormatterPath?: string;
}
export declare enum CaseOptionEnum {
unchanged = 0,
lowercase = 1,
uppercase = 2,
capitalize = 3,
unchanged = 0,
lowercase = 1,
uppercase = 2,
capitalize = 3
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "psqlformat",
"version": "1.18.1",
"version": "1.18.2",
"main": "dist/index.js",
"bin": {
"psqlformat": "dist/bin.js"
Expand Down

0 comments on commit cefbd4c

Please sign in to comment.