Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pnpm-sync-dependencies-meta-injected

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pnpm-sync-dependencies-meta-injected - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "pnpm-sync-dependencies-meta-injected",
"version": "0.0.2",
"version": "0.0.3",
"type": "module",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -9,3 +9,3 @@ import { findRoot } from '@manypkg/find-root';

import lockfile from 'proper-lockfile';
import resolvePackagePath from 'resolve-package-path';
import resolvePackageManifestPath from 'resolve-package-path';

@@ -18,4 +18,2 @@ const require = createRequire(import.meta.url);

export default async function syncPnpm(dir = process.cwd()) {
console.log(dir);
const root = await findRoot(dir);

@@ -37,31 +35,66 @@ const ownPackageJson = await readJson(join(dir, 'package.json'));

for (const pkg of packagesToSync) {
let name = pkg.packageJson.name;
/**
* This likely won't happen, but we can't have declared
* a dependency on a package without a name.
*/
if (!name) continue;
const syncFrom = join(pkg.dir, syncDir);
const resolvedPackagePath = dirname(
resolvePackagePath(pkg.packageJson.name, dir)
);
const resolvedPackagePath = resolvePackagePath(name, dir);
const syncTo = join(resolvedPackagePath, syncDir);
if (await pathExists(syncFrom)) {
let releaseLock;
await syncPkg(syncFrom, syncTo);
}
}
try {
releaseLock = await lockfile.lock(syncTo, { realpath: false });
debug(`lockfile created for syncing to ${syncTo}`);
} catch (e) {
debug(
`lockfile already exists for syncing to ${syncTo}, some other sync process is already handling this directory, so skipping...`
);
continue;
}
/**
* @param {string} name
* @param {string} startingDirectory resolve from here
*/
function resolvePackagePath(name, startingDirectory) {
const resolvedManifestPath = resolvePackageManifestPath(
name,
startingDirectory
);
if (await pathExists(syncTo)) {
await remove(syncTo);
debug(`removed ${syncTo} before syncing`);
}
if (!resolvedManifestPath) {
throw new Error(`Could not find package, ${name}`);
}
debug(`syncing from ${syncFrom} to ${syncTo}`);
await hardLinkDir(syncFrom, [syncTo]);
releaseLock();
const resolvedPackagePath = dirname(resolvedManifestPath);
return resolvedPackagePath;
}
/**
* @param {string} syncFrom
* @param {string} syncTo
*/
async function syncPkg(syncFrom, syncTo) {
if (await pathExists(syncFrom)) {
let releaseLock;
try {
releaseLock = await lockfile.lock(syncTo, { realpath: false });
debug(`lockfile created for syncing to ${syncTo}`);
} catch (e) {
debug(
`lockfile already exists for syncing to ${syncTo}, some other sync process is already handling this directory, so skipping...`
);
return;
}
if (await pathExists(syncTo)) {
await remove(syncTo);
debug(`removed ${syncTo} before syncing`);
}
debug(`syncing from ${syncFrom} to ${syncTo}`);
await hardLinkDir(syncFrom, [syncTo]);
releaseLock();
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc