json-sort-cli 3.0.12 → 3.1.0

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/CHANGELOG.md +6 -0
  2. package/cli.js +12 -4
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.1.0](https://github.com/codsen/codsen/compare/json-sort-cli@3.0.12...json-sort-cli@3.1.0) (2023-04-16)
7
+
8
+ ### Features
9
+
10
+ - `-l` or `--lineEnding` flag to override the default - the EOL format found in file (or LF) ([1788a77](https://github.com/codsen/codsen/commit/1788a7701629713a1b9ad9b992ad01aa7d456068))
11
+
6
12
  ## 3.0.7 (2023-01-06)
7
13
 
8
14
  ### Bug Fixes
package/cli.js CHANGED
@@ -12,7 +12,7 @@ import pReduce from "p-reduce";
12
12
  import pFilter from "p-filter";
13
13
  import { globby } from "globby";
14
14
  import { createRequire } from "module";
15
- import { isPlainObject } from "codsen-utils";
15
+ import { isPlainObject, resolveEolSetting } from "codsen-utils";
16
16
  import updateNotifier from "update-notifier";
17
17
  import { traverse } from "ast-monkey-traverse";
18
18
  import sortPackageJson, { sortOrder } from "sort-package-json";
@@ -66,7 +66,7 @@ const cli = meow(
66
66
  Options
67
67
  -n, --nodemodules Don't ignore any node_modules folders
68
68
  -t, --tabs Use tabs for JSON file indentation
69
- -i, --indentationCount How many spaces or tabs to use (default = 2 spaces or 1 tab)
69
+ -i, --indentationCount How many spaces/tabs to use (default: 2 for spaces or 1 for tabs)
70
70
  -s, --silent Does not show the result per-file, only totals in the end
71
71
  -h, --help Shows this help
72
72
  -v, --version Shows the current version
@@ -74,6 +74,8 @@ const cli = meow(
74
74
  -d, --dry Only list all the files about to be processed
75
75
  -p, --pack Exclude all package.json files
76
76
  -c, --ci Only exits with non-zero code if files COULD BE sorted
77
+ -l, --lineEnding Set to "cr", "crlf" or "lf" to override the default
78
+ (which is either EOL format used in the file, or Mac LF)
77
79
 
78
80
  Example
79
81
  Call anywhere using glob patterns. If you put them as string, this library
@@ -131,6 +133,10 @@ const cli = meow(
131
133
  type: "number",
132
134
  alias: "i",
133
135
  },
136
+ lineEnding: {
137
+ type: "string",
138
+ alias: "l",
139
+ },
134
140
  },
135
141
  }
136
142
  );
@@ -194,6 +200,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
194
200
  spaces: cli.flags.tabs
195
201
  ? "\t".repeat(indentationCount)
196
202
  : indentationCount,
203
+ EOL: resolveEolSetting(filesContent, cli.flags.lineEnding),
197
204
  }
198
205
  );
199
206
  } else {
@@ -258,6 +265,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
258
265
  spaces: cli.flags.tabs
259
266
  ? "\t".repeat(indentationCount)
260
267
  : indentationCount,
268
+ EOL: resolveEolSetting(filesContent, cli.flags.lineEnding),
261
269
  }
262
270
  )
263
271
  .then(() => {
@@ -318,8 +326,8 @@ globby(input, { dot: true })
318
326
  .then((paths) =>
319
327
  pReduce(
320
328
  paths,
321
- (concattedTotal, singleDirOrFilePath) =>
322
- concattedTotal.concat(
329
+ (concatTotal, singleDirOrFilePath) =>
330
+ concatTotal.concat(
323
331
  isDirectory(singleDirOrFilePath).then((bool) =>
324
332
  bool
325
333
  ? globby(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-sort-cli",
3
- "version": "3.0.12",
3
+ "version": "3.1.0",
4
4
  "description": "Command line app to deep sort JSON files, retains package.json special key order",
5
5
  "keywords": [
6
6
  "app",
@@ -67,9 +67,9 @@
67
67
  }
68
68
  },
69
69
  "dependencies": {
70
- "ast-monkey-traverse": "^4.0.8",
70
+ "ast-monkey-traverse": "^4.0.9",
71
71
  "chalk": "^5.2.0",
72
- "codsen-utils": "^1.3.1",
72
+ "codsen-utils": "^1.4.0",
73
73
  "fs-extra": "^11.1.1",
74
74
  "globby": "^13.1.4",
75
75
  "is-d": "^1.0.0",