Open Kolobok12309 opened 1 year ago
for no-op updates, it's totally reasonable that this tool should maybe do a content-check on all the files and only create links for what's changed, rather than everything. I like this idea a lot, actually. thank you <3
This is the underlying tool used tho:
So it's likely that the behavior to fix is there, especially as you describe the problem you're experiencing to be in both pnpm install
and the script from this tool.
Code like this, fix my problem for the first purpose.
let watcher = new Watcher(fromPaths, {
ignoreInitial: true,
recursive: true,
});
// Mb useless var
let actionPromise = Promise.resolve();
const getTargetPath = (sourcePath) => {
let path = fromPaths.find((p) => sourcePath.startsWith(p));
if (path === undefined) {
debug(`path not under watched root ${dirtyPath}`);
return null;
} else {
return sourcePath.replace(path, paths[path]);
}
};
watcher.on('add', async (sourcePath) => {
const targetPath = getTargetPath(sourcePath);
await actionPromise;
actionPromise = new Promise(async (res) => {
try {
debug(`link or copy file "${targetPath}"`);
await linkOrCopyFile(sourcePath, targetPath);
} finally {
res();
}
});
await actionPromise;
});
watcher.on('unlink', async (sourcePath) => {
const targetPath = getTargetPath(sourcePath);
await actionPromise;
actionPromise = new Promise(async (res) => {
try {
debug(`unlink file "${targetPath}"`);
await remove(targetPath);
} finally {
res();
}
});
await actionPromise;
});
... same for folders
File changes handled by hard-links(or mb if it not link we can update it), add/unlink handled by this watchers
It only for watch mode
P.S. How i can use fork of your repo in our projects without customize file structure? Monorepo not so good for this
Or you can simply add recursive: true,
to watcher and make it optional, it's although worked, but not delete existed files/folders)
How i can use fork of your repo in our projects without customize file structure?
How do you mean? You can use pnpm link to test local changes to this code.
Monorepo not so good for this
Sure it is!
We have library for nuxt application and
pnpm install
or your script trigger full project rebuild, even if none of the files have been modified. Simple hard-links worked perfect, but their can't help with creation or deleting files...Can you give some advice for that case?
Currently i see only one way, watcher for create/delete files and synchronously create hard-link or delete file