@elliots/typical-tsc-plugin 0.2.4 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliots/typical-tsc-plugin",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "TSC plugin for typical - runtime safe TypeScript transformer",
5
5
  "keywords": [
6
6
  "runtime",
@@ -42,7 +42,7 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@elliots/typical": "0.2.4",
45
+ "@elliots/typical": "0.2.5",
46
46
  "deasync": "0.1.30",
47
47
  "strip-json-comments": "5.0.3"
48
48
  },
@@ -1,41 +1,45 @@
1
1
  // monkeypatch fs.readFileSync to automatically add @elliots/typical-tsc-plugin to tsconfig.json (if not present)
2
2
 
3
- const fs = require('fs')
4
- const stripJsonComments = require('strip-json-comments').default
3
+ const fs = require("fs");
4
+ const stripJsonComments = require("strip-json-comments").default;
5
5
 
6
- const origFsReadFileSync = fs.readFileSync
6
+ const origFsReadFileSync = fs.readFileSync;
7
7
 
8
8
  fs.readFileSync = function (path, ...args) {
9
- const result = origFsReadFileSync.call(this, path, ...args)
9
+ const result = origFsReadFileSync.call(this, path, ...args);
10
10
 
11
- if (typeof path === 'string' && path.endsWith('/tsconfig.json')) {
11
+ if (typeof path === "string" && path.endsWith("/tsconfig.json")) {
12
12
  try {
13
- const json = stripJsonComments(result.toString(), { trailingCommas: true })
13
+ const json = stripJsonComments(result.toString(), { trailingCommas: true });
14
14
 
15
- const config = JSON.parse(json)
15
+ const config = JSON.parse(json);
16
16
 
17
17
  if (!config.compilerOptions) {
18
- config.compilerOptions = {}
18
+ config.compilerOptions = {};
19
19
  }
20
20
 
21
21
  if (!config.compilerOptions.plugins) {
22
- config.compilerOptions.plugins = []
22
+ config.compilerOptions.plugins = [];
23
23
  }
24
24
 
25
- const hasTypical = config.compilerOptions.plugins.some(plugin => plugin.transform === '@elliots/typical-tsc-plugin' || plugin.transform === '@elliots/typical/tsc-plugin')
25
+ const hasTypical = config.compilerOptions.plugins.some(
26
+ (plugin) =>
27
+ plugin.transform === "@elliots/typical-tsc-plugin" ||
28
+ plugin.transform === "@elliots/typical/tsc-plugin",
29
+ );
26
30
 
27
31
  if (!hasTypical) {
28
32
  config.compilerOptions.plugins.push({
29
- transform: '@elliots/typical-tsc-plugin',
33
+ transform: "@elliots/typical-tsc-plugin",
30
34
  transformProgram: true,
31
- })
35
+ });
32
36
  }
33
37
 
34
- return JSON.stringify(config, null, 2)
38
+ return JSON.stringify(config, null, 2);
35
39
  } catch (e) {
36
- console.error('ERROR patching tsconfig.json to add @elliots/typical-tsc-plugin', e)
37
- throw e
40
+ console.error("ERROR patching tsconfig.json to add @elliots/typical-tsc-plugin", e);
41
+ throw e;
38
42
  }
39
43
  }
40
- return result
41
- }
44
+ return result;
45
+ };