prettify-bru 0.1.12 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import yargs from 'yargs';
4
4
  import {hideBin} from 'yargs/helpers';
5
- import {main} from './lib/main.js';
5
+ import {main} from './lib/main.mjs';
6
6
 
7
7
  const argv = yargs(hideBin(process.argv))
8
8
  .command('$0 [path] [-w|--write]', `Formats all .bru files (including subdirectories)`, (yargs) => {
@@ -1,16 +1,13 @@
1
- /**
2
- * Uses Prettier to format blocks of JSON/JavaScript
3
- */
4
-
5
1
  import prettier from 'prettier'
6
2
 
7
3
  // This Prettier config should match what the Bruno GUI implements
8
4
  const prettierConfig = {
5
+ semi: false,
9
6
  tabWidth: 4,
10
7
  useTabs: false,
11
8
  bracketSpacing: false,
12
9
  trailingComma: "none",
13
- endOfLine: "endOfLine",
10
+ endOfLine: "lf",
14
11
  }
15
12
 
16
13
  const formattableBlocks = [
@@ -21,6 +18,7 @@ const formattableBlocks = [
21
18
  ]
22
19
 
23
20
 
21
+ /** Uses Prettier to format blocks of JSON/JavaScript */
24
22
  export async function formatBlocks(originalContents) {
25
23
 
26
24
  let fileOutcome = {
@@ -60,10 +58,7 @@ async function formatBlock(fileContents, blockName, parser) {
60
58
  let prettierFormatted;
61
59
 
62
60
  try {
63
- prettierFormatted = await prettier.format(unindented, {
64
- prettierConfig,
65
- parser,
66
- }).then((formatted) => formatted);
61
+ prettierFormatted = await prettier.format(unindented, Object.assign(prettierConfig, {parser}));
67
62
  } catch (e) {
68
63
  outcome.error_message = `Prettier could not format ${blockName} because...\n${e.message}`;
69
64
  return outcome
@@ -1,12 +1,9 @@
1
- /**
2
- * Finds all .bru files and formats contents
3
- */
4
-
5
1
  import fs from 'fs'
6
2
  import path from 'path'
7
- import {formatBlocks} from './format.js'
3
+ import {formatBlocks} from './format.mjs'
8
4
 
9
5
  /**
6
+ * Finds all .bru files and formats contents
10
7
  *
11
8
  * @param cwd {String} Current working directory
12
9
  * @param path {String}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettify-bru",
3
- "version": "0.1.12",
3
+ "version": "1.0.1",
4
4
  "description": "Prettifies JSON and JavaScript blocks in Bruno .bru files",
5
5
  "keywords": [
6
6
  "bruno",
@@ -23,7 +23,6 @@
23
23
  "author": "Martin Joiner (https://martinjoiner.co.uk)",
24
24
  "type": "module",
25
25
  "files": [
26
- "index.js",
27
26
  "cli.js",
28
27
  "lib/"
29
28
  ],
@@ -33,6 +32,10 @@
33
32
  "yargs": "18.0.0"
34
33
  },
35
34
  "scripts": {
36
- "test": "test"
35
+ "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
36
+ },
37
+ "devDependencies": {
38
+ "@jest/globals": "^30.2.0",
39
+ "jest": "^30.2.0"
37
40
  }
38
41
  }