����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /home/real/node-v13.0.1/deps/npm/test/tap/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/real/node-v13.0.1/deps/npm/test/tap/install-save-consistent-newlines.js
'use strict'

const fs = require('graceful-fs')
const path = require('path')

const mkdirp = require('mkdirp')
const mr = require('npm-registry-mock')
const osenv = require('osenv')
const rimraf = require('rimraf')
const test = require('tap').test

const common = require('../common-tap.js')

const pkg = common.pkg

const EXEC_OPTS = { cwd: pkg }

const json = {
  name: 'install-save-consistent-newlines',
  version: '0.0.1',
  description: 'fixture'
}

var server

test('setup', function (t) {
  setup('\n')
  mr({ port: common.port }, function (er, s) {
    server = s
    t.end()
  })
})

test('\'npm install --save\' should keep the original package.json line endings (LF)', function (t) {
  common.npm(
    [
      '--loglevel', 'silent',
      '--registry', common.registry,
      '--save',
      'install', '[email protected]'
    ],
    EXEC_OPTS,
    function (err, code) {
      t.ifError(err, 'npm ran without issue')
      t.notOk(code, 'npm install exited without raising an error code')

      const pkgPath = path.resolve(pkg, 'package.json')
      const pkgStr = fs.readFileSync(pkgPath, 'utf8')

      t.match(pkgStr, '\n')
      t.notMatch(pkgStr, '\r')

      const pkgLockPath = path.resolve(pkg, 'package-lock.json')
      const pkgLockStr = fs.readFileSync(pkgLockPath, 'utf8')

      t.match(pkgLockStr, '\n')
      t.notMatch(pkgLockStr, '\r')

      t.end()
    }
  )
})

test('\'npm install --save\' should keep the original package.json line endings (CRLF)', function (t) {
  setup('\r\n')

  common.npm(
    [
      '--loglevel', 'silent',
      '--registry', common.registry,
      '--save',
      'install', '[email protected]'
    ],
    EXEC_OPTS,
    function (err, code) {
      t.ifError(err, 'npm ran without issue')
      t.notOk(code, 'npm install exited without raising an error code')

      const pkgPath = path.resolve(pkg, 'package.json')
      const pkgStr = fs.readFileSync(pkgPath, 'utf8')

      t.match(pkgStr, '\r\n')
      t.notMatch(pkgStr, /[^\r]\n/)

      const pkgLockPath = path.resolve(pkg, 'package-lock.json')
      const pkgLockStr = fs.readFileSync(pkgLockPath, 'utf8')

      t.match(pkgLockStr, '\r\n')
      t.notMatch(pkgLockStr, /[^\r]\n/)

      t.end()
    }
  )
})

test('cleanup', function (t) {
  server.close()
  cleanup()
  t.end()
})

function cleanup () {
  process.chdir(osenv.tmpdir())
  rimraf.sync(pkg)
}

function setup (lineEnding) {
  cleanup()
  mkdirp.sync(path.resolve(pkg, 'node_modules'))

  var jsonStr = JSON.stringify(json, null, 2)

  if (lineEnding === '\r\n') {
    jsonStr = jsonStr.replace(/\n/g, '\r\n')
  }

  fs.writeFileSync(
    path.join(pkg, 'package.json'),
    jsonStr
  )
  process.chdir(pkg)
}

ZeroDay Forums Mini