403Webshell
Server IP : 46.62.235.243  /  Your IP : 216.73.216.200
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux Linkabili3Dicembre 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/thread-self/root/usr/share/node_modules/libtap/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/usr/share/node_modules/libtap/lib/fixture.js
const {writeFileSync, linkSync, statSync, symlinkSync} = require('fs')
const {mkdirRecursiveSync} = require('../settings')
const {resolve, dirname} = require('path')

class Fixture {
  constructor (type, content) {
    this.type = type
    this.content = content
    switch (type) {
      case 'dir':
        if (!content || typeof content !== 'object')
          throw new TypeError('dir fixture must have object content')
        break
      case 'file':
        if (typeof content !== 'string' && !Buffer.isBuffer(content))
          throw new TypeError('file fixture must have string/buffer content')
        break
      case 'link':
      case 'symlink':
        if (typeof content !== 'string')
          throw new TypeError(type + ' fixture must have string target')
        break
      default:
        throw new Error('invalid fixture type: ' + type)
    }
  }

  get [Symbol.toStringTag] () {
    return 'Fixture<' + this.type + '>'
  }

  // have to gather up symlinks for the end
  static make (abs, f, symlinks = null) {
    if (typeof f === 'string' || Buffer.isBuffer(f))
      f = new Fixture('file', f)
    else if (f && typeof f === 'object' && !(f instanceof Fixture))
      f = new Fixture('dir', f)
    else if (!(f instanceof Fixture))
      throw new Error('invalid fixture type: ' + f)

    const isRoot = symlinks === null
    symlinks = symlinks || {}

    switch (f.type) {
      case 'symlink':
        // have to gather up symlinks for the end, because windows
        symlinks[abs] = f.content
        break
      case 'link':
        linkSync(resolve(dirname(abs), f.content), abs)
        break
      case 'dir':
        mkdirRecursiveSync(abs)
        for (const [name, fixture] of Object.entries(f.content))
          Fixture.make(`${abs}/${name}`, fixture, symlinks)
        break
      case 'file':
        writeFileSync(abs, f.content)
        break
    }

    // create all those symlinks we were asked for
    if (isRoot) {
      for (const [abs, target] of Object.entries(symlinks)) {
        symlinkSync(target, abs, isDir(abs, target) ? 'junction' : 'file')
      }
    }
  }
}

// check if a symlink target is a directory
const isDir = (abs, target) => {
  try {
    return statSync(resolve(dirname(abs), target)).isDirectory()
  } catch (er) {
    return false
  }
}

module.exports = Fixture

Youez - 2016 - github.com/yon3zu
LinuXploit