getCacheIdentifier.js 584 B

123456789101112131415161718192021
  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. 'use strict';
  8. module.exports = function getCacheIdentifier(environment, packages) {
  9. let cacheIdentifier = environment == null ? '' : environment.toString();
  10. for (const packageName of packages) {
  11. cacheIdentifier += `:${packageName}@`;
  12. try {
  13. cacheIdentifier += require(`${packageName}/package.json`).version;
  14. } catch (_) {
  15. // ignored
  16. }
  17. }
  18. return cacheIdentifier;
  19. };