@awsless/ts-file-cache 0.0.18 → 0.0.19

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/dist/index.cjs CHANGED
@@ -74,7 +74,7 @@ const findImports = async (file, code) => {
74
74
  const findFile = async (files) => {
75
75
  for (const file of files) try {
76
76
  if ((await (0, fs_promises.stat)(file)).isFile()) return file;
77
- } catch (_) {
77
+ } catch {
78
78
  continue;
79
79
  }
80
80
  throw new Error(`No such file: ${files.join(", ")}`);
@@ -114,7 +114,7 @@ const generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedE
114
114
  try {
115
115
  file = await resolveModuleImportFile(file, allowedExtensions);
116
116
  } catch (error) {
117
- throw new Error(`Can't find imported file: "${file}" inside the source: "${sourceFile}"`);
117
+ throw new Error(`Can't find imported file: "${file}" inside the source: "${sourceFile}"`, { cause: error });
118
118
  }
119
119
  const relFile = (0, path.relative)(workspace.cwd, file).split(path.sep).join("/");
120
120
  if (hashes.has(relFile)) return;
@@ -140,11 +140,11 @@ const generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedE
140
140
  }
141
141
  return;
142
142
  }
143
- if (node_module.builtinModules.includes(module.replace(/^node\:/, ""))) return;
143
+ if (node_module.builtinModules.includes(module.replace(/^node:/, ""))) return;
144
144
  throw new Error(`Can't find the dependency version for: ${file} inside the source: ${sourceFile}`);
145
145
  };
146
146
  const mergeHashes = (hashes) => {
147
- const names = Array.from(hashes.keys()).sort();
147
+ const names = Array.from(hashes.keys()).toSorted();
148
148
  const merged = (0, crypto.createHash)("sha1");
149
149
  for (const name of names) {
150
150
  merged.update(name);
@@ -160,7 +160,7 @@ const getPackageName = (importee) => {
160
160
  throw new Error(`Malformed importee: ${importee}`);
161
161
  };
162
162
  const findDependency = (workspace, module, source) => {
163
- const pkg = Object.values(workspace.packages).filter((p) => source === p.path || source.startsWith(p.path + path.sep)).sort((a, b) => b.path.split(path.sep).length - a.path.split(path.sep).length).find((p) => p.dependencies[module]);
163
+ const pkg = Object.values(workspace.packages).filter((p) => source === p.path || source.startsWith(p.path + path.sep)).toSorted((a, b) => b.path.split(path.sep).length - a.path.split(path.sep).length).find((p) => p.dependencies[module]);
164
164
  if (!pkg) return;
165
165
  return pkg.dependencies[module];
166
166
  };
@@ -219,7 +219,7 @@ const bun = async (cwd, lockFile) => {
219
219
  const parseJsonc = (text) => {
220
220
  try {
221
221
  return JSON.parse(text);
222
- } catch (_) {
222
+ } catch {
223
223
  return JSON.parse(stripJsoncSyntax(text));
224
224
  }
225
225
  };
@@ -317,7 +317,7 @@ const loadPackageManager = async (search, level = 5) => {
317
317
  const fileExist = async (file) => {
318
318
  try {
319
319
  if ((await (0, fs_promises.lstat)(file)).isFile()) return true;
320
- } catch (error) {}
320
+ } catch {}
321
321
  return false;
322
322
  };
323
323
  const buildPackages = async (cwd, importers) => {
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ const findImports = async (file, code) => {
73
73
  const findFile = async (files) => {
74
74
  for (const file of files) try {
75
75
  if ((await stat(file)).isFile()) return file;
76
- } catch (_) {
76
+ } catch {
77
77
  continue;
78
78
  }
79
79
  throw new Error(`No such file: ${files.join(", ")}`);
@@ -113,7 +113,7 @@ const generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedE
113
113
  try {
114
114
  file = await resolveModuleImportFile(file, allowedExtensions);
115
115
  } catch (error) {
116
- throw new Error(`Can't find imported file: "${file}" inside the source: "${sourceFile}"`);
116
+ throw new Error(`Can't find imported file: "${file}" inside the source: "${sourceFile}"`, { cause: error });
117
117
  }
118
118
  const relFile = relative(workspace.cwd, file).split(sep).join("/");
119
119
  if (hashes.has(relFile)) return;
@@ -139,11 +139,11 @@ const generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedE
139
139
  }
140
140
  return;
141
141
  }
142
- if (builtinModules.includes(module.replace(/^node\:/, ""))) return;
142
+ if (builtinModules.includes(module.replace(/^node:/, ""))) return;
143
143
  throw new Error(`Can't find the dependency version for: ${file} inside the source: ${sourceFile}`);
144
144
  };
145
145
  const mergeHashes = (hashes) => {
146
- const names = Array.from(hashes.keys()).sort();
146
+ const names = Array.from(hashes.keys()).toSorted();
147
147
  const merged = createHash("sha1");
148
148
  for (const name of names) {
149
149
  merged.update(name);
@@ -159,7 +159,7 @@ const getPackageName = (importee) => {
159
159
  throw new Error(`Malformed importee: ${importee}`);
160
160
  };
161
161
  const findDependency = (workspace, module, source) => {
162
- const pkg = Object.values(workspace.packages).filter((p) => source === p.path || source.startsWith(p.path + sep)).sort((a, b) => b.path.split(sep).length - a.path.split(sep).length).find((p) => p.dependencies[module]);
162
+ const pkg = Object.values(workspace.packages).filter((p) => source === p.path || source.startsWith(p.path + sep)).toSorted((a, b) => b.path.split(sep).length - a.path.split(sep).length).find((p) => p.dependencies[module]);
163
163
  if (!pkg) return;
164
164
  return pkg.dependencies[module];
165
165
  };
@@ -218,7 +218,7 @@ const bun = async (cwd, lockFile) => {
218
218
  const parseJsonc = (text) => {
219
219
  try {
220
220
  return JSON.parse(text);
221
- } catch (_) {
221
+ } catch {
222
222
  return JSON.parse(stripJsoncSyntax(text));
223
223
  }
224
224
  };
@@ -316,7 +316,7 @@ const loadPackageManager = async (search, level = 5) => {
316
316
  const fileExist = async (file) => {
317
317
  try {
318
318
  if ((await lstat(file)).isFile()) return true;
319
- } catch (error) {}
319
+ } catch {}
320
320
  return false;
321
321
  };
322
322
  const buildPackages = async (cwd, importers) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/ts-file-cache",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "bugs": {
5
5
  "url": "https://github.com/awsless/awsless/issues"
6
6
  },