all-module-paths
Advanced tools
Comparing version 0.7.1 to 0.8.0
110
package.json
{ | ||
"name": "all-module-paths", | ||
"description": "sasas", | ||
"license": "Apache-2.0", | ||
"licenseStart": "2018", | ||
"scripts": { | ||
"start": "tunnckocore-scripts", | ||
"docs": "yarn start docks --outfile .verb.md && verb", | ||
"lint": "yarn start eslint '**/*.js' --cache --fix --quiet --format codeframe", | ||
"test-only": "node -r esm test", | ||
"test": "nyc node test", | ||
"precommit": "yarn run lint && yarn run test-only", | ||
"commit": "yarn dry", | ||
"dry": "git add -A && git status --porcelain && yarn start gitcommit" | ||
"version": "0.8.0", | ||
"description": "Get all possible javascript (npm/yarn/pnpm) global or local, binaries or packages paths, e.g. node_modules and node_modules/.bin. Also works for those using NVM or such", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/tunnckoCore/opensource.git", | ||
"directory": "packages/all-module-paths" | ||
}, | ||
"homepage": "https://tunnckocore.com/opensource", | ||
"author": "Charlike Mike Reagent <opensource@tunnckocore.com> (https://tunnckocore.com)", | ||
"license": "MPL-2.0", | ||
"engines": { | ||
"node": "^8.10.0 || >=10.13.0" | ||
"node": ">=10.13" | ||
}, | ||
"dependencies": { | ||
"esm": "^3.0.84", | ||
"global-dirs": "^0.1.1" | ||
}, | ||
"devDependencies": { | ||
"@tunnckocore/scripts": "^1.1.0", | ||
"asia": "^1.0.0-rc.6", | ||
"docks": "^0.6.1" | ||
}, | ||
"main": "src/main.js", | ||
"module": "src/index.js", | ||
"typings": "index.d.ts", | ||
"files": [ | ||
"src", | ||
"index.js" | ||
"index.d.ts" | ||
], | ||
"main": "index.js", | ||
"module": "src/index.js", | ||
"typings": "src/index.d.ts", | ||
"version": "0.7.1", | ||
"repository": "tunnckoCoreLabs/all-module-paths", | ||
"homepage": "https://github.com/tunnckoCoreLabs/all-module-paths", | ||
"author": "Charlike Mike Reagent (https://tunnckocore.com)", | ||
"keywords": [ | ||
"tunnckocorehq", | ||
"tunnckocore-oss", | ||
"hela", | ||
"development", | ||
"developer-experience", | ||
"dx", | ||
"utils", | ||
"module", | ||
"module-paths", | ||
"paths", | ||
"global-modules", | ||
"local-modules", | ||
"bin", | ||
"bin-paths", | ||
"binaries", | ||
"packages", | ||
"package-paths", | ||
"npm", | ||
"pnpm", | ||
"yarn", | ||
"javascript", | ||
"local", | ||
"global" | ||
], | ||
"scripts": {}, | ||
"dependencies": { | ||
"esm": "^3.2.25", | ||
"global-dirs": "^2.0.0" | ||
}, | ||
"publishConfig": { | ||
@@ -43,6 +57,15 @@ "access": "public", | ||
}, | ||
"renovate": { | ||
"extends": "tunnckocore" | ||
"jest": { | ||
"coverageThreshold": { | ||
"src/**/*.js": { | ||
"statements": 100, | ||
"branches": 100, | ||
"functions": 100, | ||
"lines": 100 | ||
} | ||
} | ||
}, | ||
"licenseStart": 2018, | ||
"verb": { | ||
"readme": "../../readme-template.md", | ||
"run": true, | ||
@@ -58,22 +81,11 @@ "toc": { | ||
], | ||
"related": { | ||
"list": [ | ||
"asia", | ||
"charlike", | ||
"docks", | ||
"gitcommit", | ||
"git-commits-since", | ||
"recommended-bump", | ||
"@tunnckocore/create-project", | ||
"@tunnckocore/config" | ||
] | ||
}, | ||
"lint": { | ||
"reflinks": true | ||
}, | ||
"reflinks": [ | ||
"new-release", | ||
"semantic-release" | ||
] | ||
} | ||
"reflinks": [], | ||
"related": { | ||
"list": [] | ||
} | ||
}, | ||
"gitHead": "dbf1b1c6891d5e7e9859cbc425b977d3790ae43c" | ||
} |
@@ -0,4 +1,6 @@ | ||
import fs from 'fs'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import mod from 'module'; | ||
import path from 'path'; | ||
import assert from 'assert'; | ||
import dirs from 'global-dirs'; | ||
@@ -8,3 +10,11 @@ | ||
export default function allModulePaths(m) { | ||
export default function allModulePaths(options = {}) { | ||
const { paths } = { paths: [], ...options }; | ||
assert(Array.isArray(paths), 'expect options.paths to be string[]'); | ||
const pnpmStoreVersions = ['3', '2', '1'].map((x) => | ||
path.join('pnpm-global', String(x), 'node_modules'), | ||
); | ||
/** | ||
@@ -15,9 +25,12 @@ * GLOBAL | ||
// Maximum up to the home directory | ||
// eslint-disable-next-line prefer-destructuring | ||
const globalPaths = mod.globalPaths | ||
.filter((x) => x.startsWith(HOMEDIR)) | ||
// ?? removing pnpm stuff from globalPaths, we later adding it again | ||
.filter((x) => { | ||
const fp = path.join('pnpm-global', '1', 'node_modules'); | ||
const condition = pnpmStoreVersions.find( | ||
(fp) => (x.includes(fp) && x.endsWith(fp)) || !x.includes(fp), | ||
); | ||
return (x.includes(fp) && x.endsWith(fp)) || !x.includes(fp); | ||
return condition; | ||
}) | ||
@@ -45,7 +58,9 @@ .filter((x) => !x.includes(path.join('pnpm-global', 'node_modules'))); | ||
// Only the pnpm-store path can be changed. | ||
const pnpmGlobal = path.join(nvmCurrent, 'pnpm-global', '1', 'node_modules'); | ||
const pnpmGlobal = pnpmStoreVersions.find((pnpmGlobalStore) => | ||
fs.existsSync(pnpmGlobalStore), | ||
); | ||
// Always first all the "official" global paths, | ||
// it's mostly always a short array of few items paths. | ||
// That ensures that the nvm's global dir is always last item. | ||
// That ensures that the nvm's global dir is always last item | ||
// We also filtering out the `vX.X.X/node_modules`, because such never exist. | ||
@@ -103,3 +118,3 @@ const globalPackages = globalPaths | ||
const localPackages = m.paths.filter((x) => x.startsWith(HOMEDIR)); | ||
const localPackages = paths.filter((x) => x.startsWith(HOMEDIR)); | ||
const localBinaries = localPackages.map((x) => path.join(x, '.bin')); | ||
@@ -106,0 +121,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
124
6874
2
70
+ Addedglobal-dirs@2.1.0(transitive)
+ Addedini@1.3.7(transitive)
- Removedglobal-dirs@0.1.1(transitive)
- Removedini@1.3.8(transitive)
Updatedesm@^3.2.25
Updatedglobal-dirs@^2.0.0