rads-db 0.1.100 → 0.1.102

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  module.exports = void 0;
7
7
  let eslint;
8
8
  let wasEslintImported = false;
9
+ let importEslintPromise;
9
10
  var _default = {
10
11
  async lint(args) {
11
12
  const {
@@ -33,15 +34,21 @@ var _default = {
33
34
  }
34
35
  };
35
36
  module.exports = _default;
36
- async function importEslint() {
37
- if (wasEslintImported) return eslint;
37
+ function importEslint() {
38
+ if (!importEslintPromise) importEslintPromise = importEslintInner();
39
+ return importEslintPromise;
40
+ }
41
+ async function importEslintInner() {
42
+ if (wasEslintImported) return;
38
43
  try {
39
44
  try {
40
45
  const eslintModule = await Promise.resolve().then(() => require("eslint/use-at-your-own-risk"));
41
46
  if (eslintModule) {
42
- eslint = new eslintModule.default.FlatESLint({
47
+ const flatEslint = new eslintModule.default.FlatESLint({
43
48
  fix: true
44
49
  });
50
+ await flatEslint.isPathIgnored("./test.js");
51
+ eslint = flatEslint;
45
52
  }
46
53
  } catch (e2) {
47
54
  const oldEslintModule = await Promise.resolve().then(() => require("eslint"));
@@ -1,5 +1,6 @@
1
1
  let eslint;
2
2
  let wasEslintImported = false;
3
+ let importEslintPromise;
3
4
  export default {
4
5
  async lint(args) {
5
6
  const { text, filepath } = args || {};
@@ -16,14 +17,21 @@ export default {
16
17
  return { messages, text: output || text };
17
18
  }
18
19
  };
19
- async function importEslint() {
20
+ function importEslint() {
21
+ if (!importEslintPromise)
22
+ importEslintPromise = importEslintInner();
23
+ return importEslintPromise;
24
+ }
25
+ async function importEslintInner() {
20
26
  if (wasEslintImported)
21
- return eslint;
27
+ return;
22
28
  try {
23
29
  try {
24
30
  const eslintModule = await import("eslint/use-at-your-own-risk");
25
31
  if (eslintModule) {
26
- eslint = new eslintModule.default.FlatESLint({ fix: true });
32
+ const flatEslint = new eslintModule.default.FlatESLint({ fix: true });
33
+ await flatEslint.isPathIgnored("./test.js");
34
+ eslint = flatEslint;
27
35
  }
28
36
  } catch (e2) {
29
37
  const oldEslintModule = await import("eslint");
@@ -43,6 +43,13 @@ var _default = {
43
43
  });
44
44
  if (result?.text) data = result.text;
45
45
  }
46
+ const dirname = _nodePath.default.dirname(filepath);
47
+ const isExistingDir = await dirExists(dirname);
48
+ if (!isExistingDir) {
49
+ await _promises.default.mkdir(dirname, {
50
+ recursive: true
51
+ });
52
+ }
46
53
  await _promises.default.writeFile(filepath, data, options);
47
54
  return result;
48
55
  },
@@ -71,6 +78,14 @@ var _default = {
71
78
  }
72
79
  };
73
80
  module.exports = _default;
81
+ async function dirExists(path2) {
82
+ try {
83
+ await _promises.default.access(path2);
84
+ return true;
85
+ } catch {
86
+ return false;
87
+ }
88
+ }
74
89
  function sanitizeFilepath(filepath) {
75
90
  const result = _nodePath.default.resolve(filepath);
76
91
  if (!result.startsWith(root)) throw new Error("Invalid path");
@@ -35,6 +35,11 @@ export default {
35
35
  if (result?.text)
36
36
  data = result.text;
37
37
  }
38
+ const dirname = path.dirname(filepath);
39
+ const isExistingDir = await dirExists(dirname);
40
+ if (!isExistingDir) {
41
+ await fs.mkdir(dirname, { recursive: true });
42
+ }
38
43
  await fs.writeFile(filepath, data, options);
39
44
  return result;
40
45
  },
@@ -64,6 +69,14 @@ export default {
64
69
  return await fs.unlink(filepath);
65
70
  }
66
71
  };
72
+ async function dirExists(path2) {
73
+ try {
74
+ await fs.access(path2);
75
+ return true;
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
67
80
  function sanitizeFilepath(filepath) {
68
81
  const result = path.resolve(filepath);
69
82
  if (!result.startsWith(root))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "0.1.100",
3
+ "version": "0.1.102",
4
4
  "files": [
5
5
  "dist",
6
6
  "drivers",