-
Notifications
You must be signed in to change notification settings - Fork 213
Add option to get package.json content #534
Add option to get package.json content #534
Conversation
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.
YAAAAAAAAAAAAAAAAS!
One change, but YAAAAAAAAAS!
packages/neutrino/src/api.js
Outdated
@@ -49,6 +50,8 @@ class Api { | |||
}); | |||
}); | |||
|
|||
options.packageJson = require(path.join(options.root, 'package.json')); // eslint-disable-line global-require |
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.
The section you removed from the node preset is essentially what we need here. We need to try to require the file, but not blow up if it's not there. Maybe we should consider setting this to an empty object? Not sure...
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.
Meh, we can leave it undefined.
Any thoughts on the option name? While |
I hear you, I think it looks awkward too. |
I'm just annoyed at the |
Meh, if anything we should probably roll with |
I can't think of a great name either really! :-) |
OK, reverting back to |
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.
Just a couple little changes.
packages/neutrino/src/api.js
Outdated
try { | ||
options.packageJson = require(path.join(options.root, 'package.json')); // eslint-disable-line global-require | ||
} catch (err) { | ||
options.packageJson = 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.
Let's use null
here instead.
packages/neutrino/src/api.js
Outdated
@@ -2,6 +2,7 @@ const Config = require('webpack-chain'); | |||
const merge = require('deepmerge'); | |||
const Future = require('fluture'); | |||
const mitt = require('mitt'); | |||
const path = require('path'); |
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.
Destructure out join
.
packages/library/index.js
Outdated
@@ -64,7 +64,8 @@ module.exports = (neutrino, opts = {}) => { | |||
} | |||
|
|||
try { | |||
const pkg = require(join(neutrino.options.root, 'package.json')); // eslint-disable-line global-require | |||
const pkg = neutrino.options.packageJson; | |||
|
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.
Remove extra blank line.
Also need to add blurbs to the docs about this option. |
We can do that in another bug if you like. |
Yes, will open up a different PR for this. Thanks for the reminder. |
* Add packageJson option to get package.json * Wrap require statement with try catch and rename packageJson * Revert pkgJson to packageJson * Nits * Remove extra blank line * Destructure out join * Use null instead of undefined for options.packageJson
* Move imagemin to image-minify Move minify to babel-minify Make minify an aggregate * Readme fixes, plugin const * Allow excluding presets by passing false in `minify` * WS * Never pass true, {} instead * Coerce true from web. * Fix short circuit * Removing log. * Sync docs/ and packages/ and other docs fixes (#528) * Docs: Sync the READMEs in docs/ and packages/ * Docs: Remove duplicate "zero upfront configuration" reference Since it appears in both the "extends from" and the main features list. * Docs: Sync the web features list with presets that extend from it * Docs: Fix description for react-components * Update outstanding changes to docs and add more detailed comments (#531) * Migrate clean options from v7 branch to master to allow all options for clean middleware (#530) * Remove json from being in options.extensions, update docs on extensions accordingly (#533) * Revert broken changes in image minification middleware's testing determination, do not join. (#536) * Revert broken changes, do not join. * Filter tests * Filter boolean * Udate CHANGELOG.md (#535) * Merge test babel config in root config to deal with JSX pragma plugin precedence (#537) * Move imagemin to image-minify Move minify to babel-minify Make minify an aggregate * Allow excluding presets by passing false in `minify` * Coerce true from web. * Improve help/incorrect usage output of CLI (#514) * Add option to get package.json content (#534) * Add packageJson option to get package.json * Wrap require statement with try catch and rename packageJson * Revert pkgJson to packageJson * Nits * Remove extra blank line * Destructure out join * Use null instead of undefined for options.packageJson * Use extensions in outstanding package (#532) * Update tests * Fix doc paths. * Merge options, minify by default when calling directly. * No style-minify yet
References #516.