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 :  /inetpub/wwwroot/parsmega.nuxt/node_modules/npm/node_modules/libnpmdiff/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /inetpub/wwwroot/parsmega.nuxt/node_modules/npm/node_modules/libnpmdiff/test/untar.js
const { resolve } = require('path')
const t = require('tap')
const pacote = require('pacote')
const untar = require('../lib/untar.js')

t.test('untar simple package', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/simple-output-2.2.1.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  })

  t.matchSnapshot([...files].join('\n'), 'should return list of filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v}`).join('\n'),
    'should return map of filenames to its contents'
  )
  t.matchSnapshot(refs.get('a/LICENSE').content, 'should have read contents')
})

t.test('untar package with folders', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/archive.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  })

  t.matchSnapshot([...files].join('\n'), 'should return list of filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v}`).join('\n'),
    'should return map of filenames to its contents'
  )
  t.matchSnapshot(
    refs.get('a/lib/utils/b.js').content,
    'should have read contents'
  )
})

t.test('filter files', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/simple-output-2.2.1.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  }, {
    diffFiles: [
      './LICENSE',
      'missing-file',
      'README.md',
    ],
  })

  t.matchSnapshot([...files].join('\n'), 'should return list of filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v.content}`).join('\n'),
    'should return map of filenames with valid contents'
  )
})

t.test('filter files using glob expressions', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/archive.tgz'))
  const cwd = t.testdir({
    lib: {
      'index.js': '',
      utils: {
        '/b.js': '',
      },
    },
    'package-lock.json': '',
    'package.json': '',
    test: {
      '/index.js': '',
      utils: {
        'b.js': '',
      },
    },
  })

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

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  }, {
    diffFiles: [
      './lib/**',
      '*-lock.json',
      'test\\*', // windows-style sep should be normalized
    ],
  })

  t.matchSnapshot([...files].join('\n'), 'should return list of filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v.content}`).join('\n'),
    'should return map of filenames with valid contents'
  )
})

t.test('match files by end of filename', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/archive.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  }, {
    diffFiles: [
      '*.js',
    ],
  })

  t.matchSnapshot([...files].join('\n'), 'should return list of filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v.content}`).join('\n'),
    'should return map of filenames with valid contents'
  )
})

t.test('filter files by exact filename', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/archive.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  }, {
    diffFiles: [
      'index.js',
    ],
  })

  t.matchSnapshot([...files].join('\n'), 'should return no filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v.content}`).join('\n'),
    'should return no filenames'
  )
})

t.test('match files by simple folder name', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/archive.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  }, {
    diffFiles: [
      'lib',
    ],
  })

  t.matchSnapshot([...files].join('\n'), 'should return list of filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v.content}`).join('\n'),
    'should return map of filenames with valid contents'
  )
})

t.test('match files by simple folder name variation', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/archive.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  }, {
    diffFiles: [
      './test/',
    ],
  })

  t.matchSnapshot([...files].join('\n'), 'should return list of filenames')
  t.matchSnapshot(
    [...refs.entries()].map(([k, v]) => `${k}: ${!!v.content}`).join('\n'),
    'should return map of filenames with valid contents'
  )
})

t.test('filter out all files', async t => {
  const item =
    await pacote.tarball(resolve('./test/fixtures/simple-output-2.2.1.tgz'))

  const {
    files,
    refs,
  } = await untar({
    item,
    prefix: 'a/',
  }, {
    diffFiles: [
      'non-matching-pattern',
    ],
  })

  t.equal(files.size, 0, 'should have no files')
  t.equal(refs.size, 0, 'should have no refs')
})

Youez - 2016 - github.com/yon3zu
LinuXploit