Skip to content
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

Readme updates & NPM keywords #6

Merged
merged 2 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
"pkg-up": "^3.1.0",
"tacker": "^0.1.2"
},
"keywords": [
"servexyz",
"npm",
"package.json",
"package",
"properties",
"get-pkg-prop",
"get package",
"get package property",
"get package properties"
],
"scripts": {
"start": "npm run dev",
"build": "webpack --mode production --display minimal",
Expand Down
43 changes: 24 additions & 19 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# get-pkg-prop

> Pass a key name, get a value from package.json

![travis CI build status](https://travis-ci.org/servexyz/get-pkg-prop.svg?branch=master)

## FAQ

<details><summary>Why</summary>

<ul>
Expand All @@ -18,7 +20,7 @@
I wanted to have a more diverse API for different situations.
<ul><li>Module self-testing? Call <code>get-pkg-prop("property")</code> without specifying package. </li>

<li>Testing child-module? Call <code>get-pkg-prop("property", "/sub/path/to/package.json")</code> with package path specified.</li>
<li>Testing child-module? Call <code>get-pkg-prop("property", "/sub/path/to/package.json")</code> with package path specified.</li>

<li>Mock testing? Create a mock package JSON object and call it with <code>get-pkg-prop("property", myPkgObj)</code>
</li>
Expand All @@ -31,59 +33,62 @@ I wanted to have a more diverse API for different situations.
## Getting Started

**Install**

```
npm install get-pkg-prop -S
```

**Add to source**
```
import { getPkgProp } from 'get-pkg-prop

```js
import { getPkgProp } from "get-pkg-prop";
```

**Use**

```js
getPkgProp("version") // x.y.z
getPkgProp("version"); // x.y.z
```


## API

<details><summary> <code>getPkgProp(szProperty)</code></h4></summary>
<hr />
<b>Where</b>

* *szProperty* is the name of the property.
- _szProperty_ is the name of the property.

<b>How</b>

* This uses [pkg-up](https://github.com/sindresorhus/pkg-up) to find the closest `package.json`.
- This uses [pkg-up](https://github.com/sindresorhus/pkg-up) to find the closest `package.json`.

<b>Why</b>

- Useful for confirmations when toggling between local linked deps and remote installed deps. I wanted to enable modules to self-report relevant meta info (like their version)

<hr />
</details>
</details>

<details><summary> <code>getPkgProp(szProperty, szPathToPackageJSON)</code></h4></summary>
<hr />
<b>Where</b>

* *szProperty* is the name of the property.
* *szPathToPackageJSON* is the path to either your package.json file or the directory which contains the package.json file.
- _szProperty_ is the name of the property.
- _szPathToPackageJSON_ is the path to either your package.json file or the directory which contains the package.json file.

<b>Why</b>

* Specifying the path allows you to access the package of sub-modules or installed dependencies.
- Specifying the path allows you to access the package of sub-modules or installed dependencies.

<hr />
</details>

<details><summary> <code>getPkgProp(szProperty, oPackageJSON)</code></h4></summary>
<hr />
<b>Where</b>

* *szProperty* is the name of the property.
* *oPackageJSON* is the JSON object which contains your package
- _szProperty_ is the name of the property.
- _oPackageJSON_ is the JSON object which contains your package

<b>Why</b>

* I added this for mock testing inline package objects.
<hr />
</details>
- I added this for mock testing inline package objects.
<hr />
</details>