Sha256: b8dfb19d778a7f02e760d9c1945fa07cd26b3d059710f1f726fa61c8458d3a63

Contents?: true

Size: 1.63 KB

Versions: 5

Compression:

Stored size: 1.63 KB

Contents

'use strict'
var path = require('path')
var fs = require('fs')
var test = require('tap').test
var osenv = require('osenv')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var common = require('../common-tap.js')

var base = path.join(__dirname, path.basename(__filename, '.js'))
var installFrom = path.join(base, 'from')
var installIn = path.join(base, 'in')

var json = {
  name: 'check-engine-reqs',
  version: '0.0.1',
  description: 'fixture',
  engines: {
    node: '1.0.0-not-a-real-version'
  }
}

test('setup', function (t) {
  setup()
  t.end()
})

var INSTALL_OPTS = ['--loglevel', 'silly']
var EXEC_OPTS = {cwd: installIn}

test('install bad engine', function (t) {
  common.npm(['install', '--engine-strict', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
    t.ifError(err, 'npm ran without issue')
    t.is(code, 1, 'npm install refused to install a package in itself')
    t.end()
  })
})
test('force install bad engine', function (t) {
  common.npm(['install', '--engine-strict', '--force', installFrom].concat(INSTALL_OPTS), EXEC_OPTS, function (err, code) {
    t.ifError(err, 'npm ran without issue')
    t.is(code, 0, 'npm install happily installed a package in itself with --force')
    t.end()
  })
})

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

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

function setup () {
  cleanup()
  mkdirp.sync(path.resolve(installFrom, 'node_modules'))
  fs.writeFileSync(
    path.join(installFrom, 'package.json'),
    JSON.stringify(json, null, 2)
  )
  mkdirp.sync(path.resolve(installIn, 'node_modules'))
  process.chdir(base)
}

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/deps/npm/test/tap/check-engine-reqs.js
node-compiler-0.9.0 vendor/node-v7.2.1/deps/npm/test/tap/check-engine-reqs.js
node-compiler-0.8.0 vendor/node-v7.2.0/deps/npm/test/tap/check-engine-reqs.js
node-compiler-0.7.0 vendor/node-v6.9.1/deps/npm/test/tap/check-engine-reqs.js
node-compiler-0.7.0 vendor/node-v7.1.0/deps/npm/test/tap/check-engine-reqs.js