Sha256: fab7c9a6a4bd89e24bf54886b5fa5248870101db26a84a375d05fab3a1184b9b

Contents?: true

Size: 856 Bytes

Versions: 7

Compression:

Stored size: 856 Bytes

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.makeStaticFileCache = makeStaticFileCache;

var _caching = require("../caching");

var fs = require("../../gensync-utils/fs");

function _fs2() {
  const data = require("fs");

  _fs2 = function () {
    return data;
  };

  return data;
}

function makeStaticFileCache(fn) {
  return (0, _caching.makeStrongCache)(function* (filepath, cache) {
    const cached = cache.invalidate(() => fileMtime(filepath));

    if (cached === null) {
      return null;
    }

    return fn(filepath, yield* fs.readFile(filepath, "utf8"));
  });
}

function fileMtime(filepath) {
  if (!_fs2().existsSync(filepath)) return null;

  try {
    return +_fs2().statSync(filepath).mtime;
  } catch (e) {
    if (e.code !== "ENOENT" && e.code !== "ENOTDIR") throw e;
  }

  return null;
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.16.1 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
disco_app-0.15.2 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
disco_app-0.18.4 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
disco_app-0.18.1 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
disco_app-0.14.0 test/dummy/node_modules/@babel/core/lib/config/files/utils.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@babel/core/lib/config/files/utils.js