This repository was archived by the owner on Oct 31, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: add sync resource detector api and service and deployment detectors #129
feat: add sync resource detector api and service and deployment detectors #129
Changes from all commits
7c82b4f
02558e3
70c6737
3612d71
9464c63
7c1bec0
6c3a3f4
794423d
0096c86
702b0ae
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
return require(path);
does the same thing.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.
I don't know why, but it gives "Error: Cannot find module 'package.json'" when I try to
require('package.json')
.Probably the
require
base path is different somehow vs thefs.readFileSync
alternative (which I believe can also bump into some edge cases where the process is not started from the service root)If you have experience on how to write it so it works, that would be great :)
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.
That's because it is looking for a package named
package.json
../package.json
tellsrequire
to look for the file.Both solutions are prone to errors from running the process from the outside of the project root folder.
I don't think there's a "canonical" way to get that without letting the user specify the root OR the path to the main
package.json
.Best way I could come up with to more or less consistently find what you are looking for is this:
EDIT: Changed the catch syntax a tiny bit to support node 8.