Skip to content

Commit

Permalink
Cache identifier follow up (#5055)
Browse files Browse the repository at this point in the history
* Tweak environment handling

* Add documentation for getCacheIdentifier
  • Loading branch information
Timer authored Sep 21, 2018
1 parent 0cfe758 commit fdc916a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/react-dev-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
This package includes some utilities used by [Create React App](https://github.com/facebook/create-react-app).<br>
Please refer to its documentation:

* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.

## Usage in Create React App Projects

Expand Down Expand Up @@ -361,3 +361,13 @@ module: {
];
}
```

#### `getCacheIdentifier(environment: string, packages: string[]): string`

Returns a cache identifier (string) consisting of the specified environment and related package versions, e.g.,

```js
var getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');

getCacheIdentifier('prod', ['react-dev-utils', 'chalk']); // # => 'prod:[email protected]:[email protected]'
```
2 changes: 1 addition & 1 deletion packages/react-dev-utils/getCacheIdentifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'use strict';

module.exports = function getCacheIdentifier(environment, packages) {
let cacheIdentifier = `${environment}`;
let cacheIdentifier = environment == null ? '' : environment.toString();
for (const packageName of packages) {
cacheIdentifier += `:${packageName}@`;
try {
Expand Down

0 comments on commit fdc916a

Please sign in to comment.