Skip to content

Commit

Permalink
bump version, error on syncTo == syncFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed May 6, 2024
1 parent 3e39592 commit c6d7add
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pnpm-sync-dependencies-meta-injected",
"version": "0.0.13",
"version": "0.0.14",
"type": "module",
"license": "MIT",
"repository": "https://github.com/NullVoxPopuli/pnpm-sync-dependencies-meta-injected",
Expand Down
24 changes: 16 additions & 8 deletions cli/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { findWorkspacePackages } from '@pnpm/find-workspace-packages';
import { hardLinkDir } from '@pnpm/fs.hard-link-dir';
import { readExactProjectManifest } from '@pnpm/read-project-manifest';
import Debug from 'debug';
import { pathExists } from 'fs-extra';
import { pathExists, remove } from 'fs-extra';
import lockfile from 'proper-lockfile';
import resolvePackageManifestPath from 'resolve-package-path';
import Watcher from 'watcher';
Expand Down Expand Up @@ -278,13 +278,21 @@ async function syncFolder(syncFrom, syncTo) {
return;
}

// In case anyone tries to add this back,
// we can't remove because it ends up removing the source files
// due to how linking now works in pnpm
//if (await pathExists(syncTo)) {
// await remove(syncTo);
// debug(`removed ${syncTo} before syncing`);
//}
// NOTE: that there is an oddity with this code:
// in some situations,
// we can't remove because it ends up removing the source files
// (like if the syncTo === syncFrom -- which happens if
// depMeta.*.inject has failed, and we resolve the original output
if (await pathExists(syncTo)) {
if (syncTo === syncFrom) {
throw new Error(
`dependency is not injected! would remove originally compiled files. at ${syncFrom}`
);
}

await remove(syncTo);
debug(`removed ${syncTo} before syncing`);
}

debug(`syncing from ${syncFrom} to ${syncTo}`);
await hardLinkDir(syncFrom, [syncTo]);
Expand Down

0 comments on commit c6d7add

Please sign in to comment.