@nsis/dent 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.mjs +10 -11
  2. package/package.json +2 -1
package/dist/index.mjs CHANGED
@@ -74,14 +74,17 @@ var rules = {
74
74
  };
75
75
 
76
76
  // src/main.ts
77
+ var defaultIndentation = 2;
77
78
  var Dent = class {
78
- options = {
79
- endOfLines: void 0,
80
- indentSize: 2,
81
- trimEmptyLines: true,
82
- useTabs: true
83
- };
79
+ options;
84
80
  constructor(options = {}) {
81
+ this.options = {
82
+ endOfLines: platform() === "win32" ? "crlf" : "lf",
83
+ indentSize: defaultIndentation,
84
+ trimEmptyLines: true,
85
+ useTabs: true,
86
+ ...options
87
+ };
85
88
  if (options.useTabs === true && options.indentSize) {
86
89
  throw Error("The indentSize option can only be mixed with useTabs");
87
90
  }
@@ -90,10 +93,6 @@ var Dent = class {
90
93
  throw Error("The indentSize option expects a positive integer");
91
94
  }
92
95
  }
93
- this.options = {
94
- ...this.options,
95
- ...options
96
- };
97
96
  }
98
97
  format(fileContents) {
99
98
  let indentationLevel = 0;
@@ -149,7 +148,7 @@ var Dent = class {
149
148
  }
150
149
  }
151
150
  getIndentChar() {
152
- return this.options.useTabs ? " ".repeat(this.options.indentSize) : " ".repeat(this.options.indentSize);
151
+ return this.options.useTabs ? " ".repeat(this.options.indentSize || defaultIndentation) : " ".repeat(this.options.indentSize || defaultIndentation);
153
152
  }
154
153
  };
155
154
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsis/dent",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "An opinionated code formatter for NSIS scripts",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -21,6 +21,7 @@
21
21
  "README.md"
22
22
  ],
23
23
  "type": "module",
24
+ "types": "./src/main.ts",
24
25
  "exports": {
25
26
  ".": {
26
27
  "import": "./dist/index.mjs"