]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/version-no-tags.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / version-no-tags.js
1 var common = require("../common-tap.js")
2 var test = require("tap").test
3 var npm = require("../../")
4 var osenv = require("osenv")
5 var path = require("path")
6 var fs = require("fs")
7 var rimraf = require("rimraf")
8 var mkdirp = require("mkdirp")
9 var which = require("which")
10 var spawn = require("child_process").spawn
11
12 var pkg = path.resolve(__dirname, "version-no-tags")
13 var cache = path.resolve(pkg, "cache")
14
15 test("npm version <semver> without git tag", function (t) {
16   setup()
17   npm.load({ cache: cache, registry: common.registry}, function () {
18     which("git", function (err, git) {
19       t.ifError(err, "git found on system")
20       function tagExists(tag, _cb) {
21         var child1 = spawn(git, ["tag", "-l", tag])
22         var out = ""
23         child1.stdout.on("data", function (d) {
24           out += d.toString()
25         })
26         child1.on("exit", function () {
27           return _cb(null, Boolean(~out.indexOf(tag)))
28         })
29       }
30
31       var child2 = spawn(git, ["init"])
32       child2.stdout.pipe(process.stdout)
33       child2.on("exit", function () {
34         npm.config.set("git-tag-version", false)
35         npm.commands.version(["patch"], function (err) {
36           if (err) return t.fail("Error perform version patch")
37           var p = path.resolve(pkg, "package")
38           var testPkg = require(p)
39           if (testPkg.version !== "0.0.1") t.fail(testPkg.version+" !== \"0.0.1\"")
40           t.equal("0.0.1", testPkg.version)
41           tagExists("v0.0.1", function (err, exists) {
42             t.ifError(err, "tag found to exist")
43             t.equal(exists, false, "git tag DOES exist")
44             t.pass("git tag does not exist")
45             t.end()
46           })
47         })
48       })
49     })
50   })
51 })
52
53 test("cleanup", function (t) {
54   // windows fix for locked files
55   process.chdir(osenv.tmpdir())
56
57   rimraf.sync(pkg)
58   t.end()
59 })
60
61 function setup() {
62   mkdirp.sync(pkg)
63   mkdirp.sync(cache)
64   fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify({
65     author: "Evan Lucas",
66     name: "version-no-tags-test",
67     version: "0.0.0",
68     description: "Test for git-tag-version flag"
69   }), "utf8")
70   process.chdir(pkg)
71 }