@prg/gatsby-source-something-whatever
Version:
something something whatever who gives a crap.
30 lines (22 loc) • 981 B
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.shouldUseOfflineCache = void 0;
var _isOnline = _interopRequireDefault(require("is-online"));
var _constants = require("./constants");
const shouldUseOfflineCache = async getNodes => {
const online = await (0, _isOnline.default)();
const isOffline = !online;
const useCache = process.env.GATSBY_USE_CACHE_OFFLINE === `true`;
const isProduction = process.env.NODE_ENV === `production`;
if (isOffline && useCache && !isProduction) {
getNodes().filter(n => n.internal.owner === _constants.PLUGIN_NAME).forEach(n => touchNode({
nodeId: n.id
}));
console.log(`Using ${_constants.PLUGIN_NAME} Offline cache⚠️`);
console.log(`Cache may be invalidated if you edit package.json, gatsby-node.js or gatsby-config.js files`);
return true;
}
return;
};
exports.shouldUseOfflineCache = shouldUseOfflineCache;