prettify-bru 0.1.8 → 0.1.9

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.
Files changed (3) hide show
  1. package/cli.js +7 -8
  2. package/index.js +11 -2
  3. package/package.json +2 -4
package/cli.js CHANGED
@@ -6,12 +6,12 @@ import { go } from './index.js';
6
6
 
7
7
  const argv = yargs(hideBin(process.argv))
8
8
  .usage(`
9
- Usage: $0 [-d] path
9
+ Usage: $0 [--write|-w] path
10
10
 
11
11
  Running the command with no arguments will modify all files
12
12
 
13
13
  `).options({
14
- d: {
14
+ w: {
15
15
  type: 'boolean',
16
16
  default: false
17
17
  },
@@ -20,18 +20,17 @@ Running the command with no arguments will modify all files
20
20
  },
21
21
  })
22
22
  .describe({
23
- d: 'Dry-run (Files will not be modified)',
24
- h: 'Display this help message',
23
+ w: 'Write mode (Formats files in place, overwriting contents)',
24
+ h: 'Display the help message',
25
25
  })
26
- .boolean(['d', 'h'])
26
+ .boolean(['w', 'h'])
27
27
  .help()
28
28
  .alias('h', 'help')
29
- .alias('d', 'check')
30
- .alias('d', 'dry-run')
29
+ .alias('w', 'write')
31
30
  .parse();
32
31
 
33
32
  if (argv.h) {
34
33
  yargs.showHelp();
35
34
  } else {
36
- go(argv.d, argv._[0]);
35
+ go(argv.w, argv._[0]);
37
36
  }
package/index.js CHANGED
@@ -1,4 +1,13 @@
1
- export function go(dryRun, path) {
1
+ export function go(path, write) {
2
+ if (path === '.') {
3
+ path = process.cwd()
4
+ } else if (!/^\//.test(path)) {
5
+ // Path is absolute, do not modify
6
+ } else {
7
+ // Turn relative path into absolute
8
+ path = process.cwd() + '/' + path
9
+ }
10
+
2
11
  console.log("go() method inside index.js");
3
- console.log(dryRun, path);
12
+ console.log(path, write);
4
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettify-bru",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Prettifies JSON and JavaScript blocks in Bruno .bru files",
5
5
  "keywords": [
6
6
  "bruno",
@@ -27,9 +27,7 @@
27
27
  "cli.js",
28
28
  "src/"
29
29
  ],
30
- "bin": {
31
- "prettify-bru": "./cli.js"
32
- },
30
+ "bin": "./cli.js",
33
31
  "dependencies": {
34
32
  "yargs": "18.0.0"
35
33
  },