⚝
One Hat Cyber Team
⚝
Your IP:
172.22.0.1
Server IP:
151.80.20.34
Server:
Linux 794f04d97d5e 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
Server Software:
Apache/2.4.62 (Debian)
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
node_modules
/
@isaacs
/
import-jsx
/
Edit File: cache.js
'use strict'; // Based on https://github.com/babel/babel-loader/blob/15df92fafd58ec53ba88efa22de7b2cee5e65fcc/src/cache.js const fs = require('fs'); const os = require('os'); const path = require('path'); const crypto = require('crypto'); const makeDir = require('make-dir'); const findCacheDir = require('find-cache-dir'); const transform = require('./transform'); let directory; /** * Build the filename for the cached file * * @param {String} source Original contents of the file to be cached * @param {Object} options Options passed to importJsx * @param {String} version Version of import-jsx * * @return {String} */ const filename = (source, options, version) => { const hash = crypto.createHash('md5'); const contents = JSON.stringify({source, options, version}); hash.update(contents); return hash.digest('hex') + '.js'; }; /** * Handle the cache * * @params {String} directory * @params {Object} parameters */ const handleCache = (directory, parameters) => { const {modulePath, options, source, version} = parameters; if (!options.cache) { return transform(source, options, modulePath); } const file = path.join(directory, filename(source, options, version)); try { // No errors mean that the file was previously cached // we just need to return it return fs.readFileSync(file).toString(); // eslint-disable-next-line no-unused-vars } catch (error) {} const fallback = directory !== os.tmpdir(); // Make sure the directory exists. try { makeDir.sync(directory); } catch (error) { if (fallback) { return handleCache(os.tmpdir(), parameters); } throw error; } // Otherwise just transform the file // return it to the user asap and write it in cache const result = transform(source, options, modulePath); try { fs.writeFileSync(file, result); } catch (error) { if (fallback) { // Fallback to tmpdir if node_modules folder not writable return handleCache(os.tmpdir(), parameters); } throw error; } return result; }; /** * Retrieve file from cache, or create a new one for future reads * * @param {Object} parameters * @param {String} parameters.modulePath * @param {String} parameters.source Original contents of the file to be cached * @param {Object} parameters.options Options passed to importJsx * @param {String} parameters.version Version of import-jsx */ module.exports = parameters => { if (!directory) { directory = findCacheDir({name: 'import-jsx'}) || os.tmpdir(); } return handleCache(directory, parameters); };
Simpan