403Webshell
Server IP : 185.208.173.17  /  Your IP : 87.236.161.98
Web Server : Microsoft-IIS/10.0
System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64
User : IUSR ( 0)
PHP Version : 7.4.13
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/inetpub/wwwroot/parsmega.nuxt/node_modules/npm/node_modules/libnpmdiff/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/npm/node_modules/libnpmdiff/test/tarball.js
const { resolve } = require('path')

const t = require('tap')
const tar = require('tar')
const pacote = require('pacote')
pacote.tarball = () => {
  throw new Error('Failed to detect node_modules tarball')
}

const tarball = require('../lib/tarball.js')

const json = (obj) => `${JSON.stringify(obj, null, 2)}\n`

t.test('returns a tarball from node_modules', t => {
  t.plan(2)

  const path = t.testdir({
    node_modules: {
      a: {
        'package.json': json({
          name: 'a',
          version: '1.0.0',
          bin: { a: 'index.js' },
        }),
        'index.js': '',
      },
    },
  })

  const _cwd = process.cwd()
  process.chdir(path)
  t.teardown(() => {
    process.chdir(_cwd)
  })

  tarball({ bin: { a: 'index.js' }, _resolved: resolve(path, 'node_modules/a') }, { where: path })
    .then(res => {
      tar.list({
        filter: path => {
          t.match(
            path,
            /package.json|index.js/,
            'should return tarball with expected files'
          )
        },
      })
        .on('error', e => {
          throw e
        })
        .end(res)
    })
})

t.test('node_modules folder within a linked dir', async t => {
  const path = t.testdir({
    node_modules: {
      a: t.fixture('symlink', '../packages/a'),
    },
    packages: {
      a: {
        node_modules: {
          b: {
            'package.json': json({
              name: 'a',
              version: '1.0.0',
            }),
          },
        },
      },
    },
  })

  const link = await tarball({ _resolved: resolve(path, 'node_modules/a/node_modules/b') }, {})
  t.ok(link, 'should retrieve tarball from reading link')

  const target = await tarball({ _resolved: resolve(path, 'packages/a/node_modules/b') }, {})
  t.ok(target, 'should retrieve tarball from reading target')
})

t.test('pkg not in a node_modules folder', async t => {
  const path = t.testdir({
    packages: {
      a: {
        'package.json': json({
          name: 'a',
          version: '1.0.0',
        }),
      },
    },
  })

  t.throws(
    () => tarball({ _resolved: resolve(path, 'packages/a') }, {}),
    'should call regular pacote.tarball method instead'
  )
})

Youez - 2016 - github.com/yon3zu
LinuXploit