The root-link-target package uses next-path, a tiny package that's published under the Mozilla Public License. That's a copyleft license, which makes it incompatible with the MIT license that root-link-target and its downstream pnpm packages are licensed under.
Here's a quick attempt at asking Claude to generate a function that achieves the same goal:
Prompt: I want to iterate over all directories between a start and end directory in Node.js, where one is nested in the other. For example, with start = /a and end = /a/b/c, the directories I'd iterate over would be /a, /a/b, and /a/b/c. Please generate a function for this.
Claude: Here's a function that iterates over all directories in the path between a start and end directory:
const path = require('path');
function* getDirectoriesBetween(startDir, endDir) {
// Normalize paths to remove any trailing slashes and resolve relative paths
const normalizedStart = path.normalize(startDir);
const normalizedEnd = path.normalize(endDir);
// Verify that end directory is nested within start directory
if (!normalizedEnd.startsWith(normalizedStart)) {
throw new Error('End directory must be nested within start directory');
}
// Split the relative path into components
const relativePath = path.relative(normalizedStart, normalizedEnd);
const parts = relativePath.split(path.sep);
// Start with the initial directory
let currentPath = normalizedStart;
yield currentPath;
// Iterate through each part and build up the path
for (const part of parts) {
currentPath = path.join(currentPath, part);
yield currentPath;
}
}
// Example usage:
// for (const dir of getDirectoriesBetween('/a', '/a/b/c')) {
// console.log(dir);
// }
The root-link-target package uses next-path, a tiny package that's published under the Mozilla Public License. That's a copyleft license, which makes it incompatible with the MIT license that root-link-target and its downstream pnpm packages are licensed under.
Here's a quick attempt at asking Claude to generate a function that achieves the same goal: