Skip to content

Commit

Permalink
--deep: Fix Windows path.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Mar 22, 2021
1 parent f73eeef commit 696168b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ async function run(options = {}) {
const defaultPackageFilename = getPackageFileName(options)
const pkgs = globby.sync(options.cwd
? path.resolve(options.cwd.replace(/^~/, os.homedir()), defaultPackageFilename)
.replace(/\\/g, '/') // convert Windows path to *nix path for globby
: defaultPackageFilename, {
ignore: ['**/node_modules/**']
})
Expand All @@ -459,13 +460,17 @@ async function run(options = {}) {
else if (options.deep) {
analysis = await pkgs.reduce(async (previousPromise, packageFile) => {
const packages = await previousPromise
// Mutate packageFile for current package
options.packageFile = packageFile
const [pkgData, pkgFile] = await findPackage(options)
return {
...packages,
// index by relative path if cwd was specified
[options.cwd ? path.relative(path.resolve(options.cwd), pkgFile) : pkgFile]: await analyzeProjectDependencies(options, pkgData, pkgFile)
[options.cwd
? path.relative(path.resolve(options.cwd), pkgFile)
// convert Windows path to *nix path for consistency
.replace(/\\/g, '/')
: pkgFile
]: await analyzeProjectDependencies(options, pkgData, pkgFile)
}
}, {})
if (options.json) {
Expand Down

0 comments on commit 696168b

Please sign in to comment.