+32
-4
| // link the package folder into ./target/node_modules/<pkgname> | ||
| import { symlinkSync } from 'fs'; | ||
| import { readlinkSync, symlinkSync } from 'fs'; | ||
| import { mkdirpSync } from 'mkdirp'; | ||
| import { dirname, relative, resolve } from 'path'; | ||
| import { dirname, relative, resolve, sep } from 'path'; | ||
| import { rimrafSync } from 'rimraf'; | ||
| import { walkUp } from 'walk-up-path'; | ||
| const dirsMade = new Map(); | ||
| // if the cwd is in already linked to or living within node_modules, | ||
| // then skip the linking, because it's already done. | ||
| // This is typically the case in a workspaces setup, and | ||
| // creating yet *another* symlink to ourselves in src/node_modules | ||
| // will break nx's change detection logic with an ELOOP error. | ||
| let inNM = undefined; | ||
| const linkedAlready = (pkg) => { | ||
| if (inNM !== undefined) { | ||
| return inNM; | ||
| } | ||
| const cwd = process.cwd(); | ||
| const p = `${sep}node_modules${sep}${pkg.name}`.toLowerCase(); | ||
| if (cwd.toLowerCase().endsWith(p)) { | ||
| return (inNM = true); | ||
| } | ||
| for (const p of walkUp(cwd)) { | ||
| const link = resolve(p, 'node_modules', pkg.name); | ||
| try { | ||
| const target = resolve(dirname(link), readlinkSync(link)); | ||
| if (relative(target, cwd) === '') { | ||
| return (inNM = true); | ||
| } | ||
| } | ||
| catch { } | ||
| } | ||
| return (inNM = false); | ||
| }; | ||
| export const link = (pkg, where) => { | ||
| if (!pkg.name) | ||
| if (!pkg.name || linkedAlready(pkg)) | ||
| return; | ||
@@ -19,3 +47,3 @@ const dest = resolve(where, 'node_modules', pkg.name); | ||
| export const unlink = (pkg, where) => { | ||
| if (!pkg.name) | ||
| if (!pkg.name || linkedAlready(pkg)) | ||
| return; | ||
@@ -22,0 +50,0 @@ const dest = resolve(where, 'node_modules', pkg.name); |
+3
-2
| { | ||
| "name": "tshy", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "description": "TypeScript HYbridizer - Hybrid (CommonJS/ESM) TypeScript node package builder", | ||
@@ -19,3 +19,4 @@ "author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)", | ||
| "sync-content": "^1.0.2", | ||
| "typescript": "5.2" | ||
| "typescript": "5.2", | ||
| "walk-up-path": "^3.0.1" | ||
| }, | ||
@@ -22,0 +23,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
99994
3.14%768
3.78%8
14.29%+ Added