j9t / obsohtml

Detection of obsolete and proprietary HTML elements and attributes
https://www.npmjs.com/package/@j9t/obsohtml
Creative Commons Attribution Share Alike 4.0 International
55 stars 0 forks source link

Improve directory walk, and make warnings opt-in/opt-out #5

Closed j9t closed 1 month ago

j9t commented 1 month ago

Observed some errors when checking entire user directory. (Early AI-generated solution attached.)

Wide scans may lead to many warning messages. These would be useful to make opt-in or opt-out. (Probably opt-in, as with a -v flag.)


After function walkDirectory(directory) {:

const MAX_PATH_LENGTH = 255; // Adjust this value based on your OS limits

After const fullPath = path.join(directory, file);:

if (fullPath.length > MAX_PATH_LENGTH) {
  console.warn(`Skipping file or directory with path too long: ${fullPath}`);
  return;
}

try {
  const stats = fs.lstatSync(fullPath);
  if (stats.isSymbolicLink()) {
    console.warn(`Skipping symbolic link: ${fullPath}`);
    return;
  }

  // …
}
j9t commented 1 month ago

Prepared PR #6.

j9t commented 1 month ago

After rolling back (superfluous) test change, merged #6.