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