Sha256: e3106edc288472f60502839e1256b48867c5376d890aa2ac07716eff05f09263

Contents?: true

Size: 1.42 KB

Versions: 28

Compression:

Stored size: 1.42 KB

Contents

"use strict";

exports.__esModule = true;

var _stringify = require("babel-runtime/core-js/json/stringify");

var _stringify2 = _interopRequireDefault(_stringify);

exports.save = save;
exports.load = load;
exports.get = get;

var _path = require("path");

var _path2 = _interopRequireDefault(_path);

var _fs = require("fs");

var _fs2 = _interopRequireDefault(_fs);

var _mkdirp = require("mkdirp");

var _homeOrTmp = require("home-or-tmp");

var _homeOrTmp2 = _interopRequireDefault(_homeOrTmp);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var FILENAME = process.env.BABEL_CACHE_PATH || _path2.default.join(_homeOrTmp2.default, ".babel.json");
var data = {};

function save() {
  var serialised = "{}";

  try {
    serialised = (0, _stringify2.default)(data, null, "  ");
  } catch (err) {

    if (err.message === "Invalid string length") {
      err.message = "Cache too large so it's been cleared.";
      console.error(err.stack);
    } else {
      throw err;
    }
  }

  (0, _mkdirp.sync)(_path2.default.dirname(FILENAME));
  _fs2.default.writeFileSync(FILENAME, serialised);
}

function load() {
  if (process.env.BABEL_DISABLE_CACHE) return;

  process.on("exit", save);
  process.nextTick(save);

  if (!_fs2.default.existsSync(FILENAME)) return;

  try {
    data = JSON.parse(_fs2.default.readFileSync(FILENAME));
  } catch (err) {
    return;
  }
}

function get() {
  return data;
}

Version data entries

28 entries across 28 versions & 9 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.50 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.49 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.48 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.47 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.46 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.45 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.44 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.43 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.42 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.41 node_modules/babel-register/lib/cache.js
immosquare-cleaner-0.1.40 node_modules/babel-register/lib/cache.js
ilog-0.4.1 node_modules/babel-register/lib/cache.js
ilog-0.4.0 node_modules/babel-register/lib/cache.js
ilog-0.3.3 node_modules/babel-register/lib/cache.js
optimacms-0.4.3 spec/dummy/node_modules/babel-register/lib/cache.js
optimacms-0.4.2 spec/dummy/node_modules/babel-register/lib/cache.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/babel-register/lib/cache.js
lux_assets-0.2.11 ./node_modules/babel-register/lib/cache.js
lux_assets-0.2.9 ./node_modules/babel-register/lib/cache.js