BVB Source Codes

reactide Show cache.js Source code

Return Download reactide: download cache.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4.  
  5. var _stringify = require("babel-runtime/core-js/json/stringify");
  6.  
  7. var _stringify2 = _interopRequireDefault(_stringify);
  8.  
  9. exports.save = save;
  10. exports.load = load;
  11. exports.get = get;
  12.  
  13. var _path = require("path");
  14.  
  15. var _path2 = _interopRequireDefault(_path);
  16.  
  17. var _fs = require("fs");
  18.  
  19. var _fs2 = _interopRequireDefault(_fs);
  20.  
  21. var _mkdirp = require("mkdirp");
  22.  
  23. var _homeOrTmp = require("home-or-tmp");
  24.  
  25. var _homeOrTmp2 = _interopRequireDefault(_homeOrTmp);
  26.  
  27. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28.  
  29. var FILENAME = process.env.BABEL_CACHE_PATH || _path2.default.join(_homeOrTmp2.default, ".babel.json");
  30. var data = {};
  31.  
  32. function save() {
  33.   var serialised = "{}";
  34.  
  35.   try {
  36.     serialised = (0, _stringify2.default)(data, null, "  ");
  37.   } catch (err) {
  38.  
  39.     if (err.message === "Invalid string length") {
  40.       err.message = "Cache too large so it's been cleared.";
  41.       console.error(err.stack);
  42.     } else {
  43.       throw err;
  44.     }
  45.   }
  46.  
  47.   (0, _mkdirp.sync)(_path2.default.dirname(FILENAME));
  48.   _fs2.default.writeFileSync(FILENAME, serialised);
  49. }
  50.  
  51. function load() {
  52.   if (process.env.BABEL_DISABLE_CACHE) return;
  53.  
  54.   process.on("exit", save);
  55.   process.nextTick(save);
  56.  
  57.   if (!_fs2.default.existsSync(FILENAME)) return;
  58.  
  59.   try {
  60.     data = JSON.parse(_fs2.default.readFileSync(FILENAME));
  61.   } catch (err) {
  62.     return;
  63.   }
  64. }
  65.  
  66. function get() {
  67.   return data;
  68. }
downloadcache.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top