Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dedupe.js « tap « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9a8b31a7991dc0dbf0a5cffcdaf55f9c6bad57ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var test = require("tap").test
  , fs = require("fs")
  , path = require("path")
  , existsSync = fs.existsSync || path.existsSync
  , npm = require("../../")
  , rimraf = require("rimraf")

test("dedupe finds the common module and moves it up one level", function (t) {
  t.plan(2)

  setup(function () {
    npm.install(".", function (err) {
      if (err) return t.fail(err)
      npm.dedupe(function(err) {
        if (err) return t.fail(err)
        t.ok(existsSync(path.join(__dirname, "dedupe", "node_modules", "minimist")))
        t.ok(!existsSync(path.join(__dirname, "dedupe", "node_modules", "prime")))
      })
    })
  })
})

function setup (cb) {
  process.chdir(path.join(__dirname, "dedupe"))
  npm.load(function () {
    rimraf.sync(path.join(__dirname, "dedupe", "node_modules"))
    fs.mkdirSync(path.join(__dirname, "dedupe", "node_modules"))
    cb()
  })
}