Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Add option to get package.json content #534

Merged
merged 4 commits into from
Dec 5, 2017

Conversation

helfi92
Copy link
Member

@helfi92 helfi92 commented Dec 4, 2017

References #516.

@helfi92 helfi92 self-assigned this Dec 4, 2017
Copy link
Member

@eliperelman eliperelman left a 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!

@@ -49,6 +50,8 @@ class Api {
});
});

options.packageJson = require(path.join(options.root, 'package.json')); // eslint-disable-line global-require
Copy link
Member

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...

Copy link
Member

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.

@eliperelman
Copy link
Member

Any thoughts on the option name? While packageJson works, it seems kinda awkward. cc: @edmorley

@helfi92
Copy link
Member Author

helfi92 commented Dec 4, 2017

I hear you, I think it looks awkward too. pkgJson is slightly better. I don't like package just because it's hard to know what kind of package it is by simply looking at the name.

@eliperelman
Copy link
Member

I'm just annoyed at the Json part. I think I prefer package over packageJson, but neither make me happy. Maybe there's another word we can use?

@eliperelman
Copy link
Member

Meh, if anything we should probably roll with packageJson since it's the most descriptive and relevant. Let's see what @edmorley thinks.

@edmorley
Copy link
Member

edmorley commented Dec 4, 2017

packageMetadata, projectMetadata, ...?

I can't think of a great name either really! :-)

@helfi92
Copy link
Member Author

helfi92 commented Dec 4, 2017

OK, reverting back to packageJson 🤢 hehe

Copy link
Member

@eliperelman eliperelman left a 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.

try {
options.packageJson = require(path.join(options.root, 'package.json')); // eslint-disable-line global-require
} catch (err) {
options.packageJson = undefined;
Copy link
Member

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.

@@ -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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure out join.

@@ -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;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra blank line.

* Remove extra blank line
* Destructure out join
* Use null instead of undefined for options.packageJson
@eliperelman
Copy link
Member

Also need to add blurbs to the docs about this option.

@eliperelman
Copy link
Member

We can do that in another bug if you like.

@helfi92
Copy link
Member Author

helfi92 commented Dec 5, 2017

Yes, will open up a different PR for this. Thanks for the reminder.

@helfi92 helfi92 merged commit a653992 into neutrinojs:master Dec 5, 2017
timkelty pushed a commit that referenced this pull request Dec 5, 2017
* 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
eliperelman pushed a commit that referenced this pull request Dec 5, 2017
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

3 participants