-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use read-pkg-up
over pkg-up
.
#680
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import pkgUp from 'pkg-up' | ||
import readPkgUp from 'read-pkg-up' | ||
import minimatch from 'minimatch' | ||
import importType from '../core/importType' | ||
import isStaticRequire from '../core/staticRequire' | ||
|
||
function getDependencies(context) { | ||
const filepath = pkgUp.sync(context.getFilename()) | ||
if (!filepath) { | ||
return null | ||
} | ||
|
||
try { | ||
const packageContent = JSON.parse(fs.readFileSync(filepath, 'utf8')) | ||
const pkg = readPkgUp.sync({cwd: context.getFilename(), normalize: false}) | ||
const packageContent = JSON.parse(pkg.pkg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem that makes the build fail is that This works better: const pkg = readPkgUp.sync({cwd: context.getFilename(), normalize: false})
if (!pkg || !pkg.pkg) {
return null
}
const packageContent = pkg.pkg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, I don't know how I missed that. |
||
return { | ||
dependencies: packageContent.dependencies || {}, | ||
devDependencies: packageContent.devDependencies || {}, | ||
|
@@ -46,7 +42,6 @@ function reportIfMissing(context, deps, depsOptions, node, name) { | |
const packageName = splitName[0][0] === '@' | ||
? splitName.slice(0, 2).join('/') | ||
: splitName[0] | ||
|
||
const isInDeps = deps.dependencies[packageName] !== undefined | ||
const isInDevDeps = deps.devDependencies[packageName] !== undefined | ||
const isInOptDeps = deps.optionalDependencies[packageName] !== undefined | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this import, now that it is not used?