!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/node-red/node_modules/mocha/lib/nodejs/   drwxr-xr-x
Free 13.16 GB of 57.97 GB (22.71%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     esm-utils.js (3.47 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
const path = require('path');
const url = require('url');

const formattedImport = async file => {
  if (path.isAbsolute(file)) {
    try {
      return await import(url.pathToFileURL(file));
    } catch (err) {
      // This is a hack created because ESM in Node.js (at least in Node v15.5.1) does not emit
      // the location of the syntax error in the error thrown.
      // This is problematic because the user can't see what file has the problem,
      // so we add the file location to the error.
      // This `if` should be removed once Node.js fixes the problem.
      if (
        err instanceof SyntaxError &&
        err.message &&
        err.stack &&
        !err.stack.includes(file)
      ) {
        const newErrorWithFilename = new SyntaxError(err.message);
        newErrorWithFilename.stack = err.stack.replace(
          /^SyntaxError/,
          `SyntaxError[ @${file} ]`
        );
        throw newErrorWithFilename;
      }
      throw err;
    }
  }
  return import(file);
};

const hasStableEsmImplementation = (() => {
  const [major, minor] = process.version.split('.');
  // ESM is stable from v12.22.0 onward
  // https://nodejs.org/api/esm.html#esm_modules_ecmascript_modules
  const majorNumber = parseInt(major.slice(1), 10);
  const minorNumber = parseInt(minor, 10);
  return majorNumber > 12 || (majorNumber === 12 && minorNumber >= 22);
})();

exports.requireOrImport = hasStableEsmImplementation
  ? async file => {
      if (path.extname(file) === '.mjs') {
        return formattedImport(file);
      }
      try {
        return dealWithExports(await formattedImport(file));
      } catch (err) {
        if (
          err.code === 'ERR_MODULE_NOT_FOUND' ||
          err.code === 'ERR_UNKNOWN_FILE_EXTENSION' ||
          err.code === 'ERR_UNSUPPORTED_DIR_IMPORT'
        ) {
          try {
            return require(file);
          } catch (requireErr) {
            if (requireErr.code === 'ERR_REQUIRE_ESM') {
              // This happens when the test file is a JS file, but via type:module is actually ESM,
              // AND has an import to a file that doesn't exist.
              // This throws an `ERR_MODULE_NOT_FOUND` // error above,
              // and when we try to `require` it here, it throws an `ERR_REQUIRE_ESM`.
              // What we want to do is throw the original error (the `ERR_MODULE_NOT_FOUND`),
              // and not the `ERR_REQUIRE_ESM` error, which is a red herring.
              throw err;
            } else {
              throw requireErr;
            }
          }
        } else {
          throw err;
        }
      }
    }
  : implementationOfRequireOrImportForUnstableEsm;

function dealWithExports(module) {
  if (module.default) {
    return module.default;
  } else {
    return {...module, default: undefined};
  }
}

exports.loadFilesAsync = async (files, preLoadFunc, postLoadFunc) => {
  for (const file of files) {
    preLoadFunc(file);
    const result = await exports.requireOrImport(path.resolve(file));
    postLoadFunc(file, result);
  }
};

/* istanbul ignore next */
async function implementationOfRequireOrImportForUnstableEsm(file) {
  if (path.extname(file) === '.mjs') {
    return formattedImport(file);
  }
  // This is currently the only known way of figuring out whether a file is CJS or ESM in
  // Node.js that doesn't necessitate calling `import` first.
  try {
    return require(file);
  } catch (err) {
    if (err.code === 'ERR_REQUIRE_ESM') {
      return formattedImport(file);
    } else {
      throw err;
    }
  }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0215 ]--