UNPKG

584 BJavaScriptView Raw
1/**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8'use strict';
9
10module.exports = function getCacheIdentifier(environment, packages) {
11 let cacheIdentifier = environment == null ? '' : environment.toString();
12 for (const packageName of packages) {
13 cacheIdentifier += `:${packageName}@`;
14 try {
15 cacheIdentifier += require(`${packageName}/package.json`).version;
16 } catch (_) {
17 // ignored
18 }
19 }
20 return cacheIdentifier;
21};