update smartci to have simpler exported logic

This commit is contained in:
Philipp Kunz 2016-07-28 01:22:06 +02:00
parent a92f7032ed
commit 353be042ea
24 changed files with 85 additions and 4815 deletions

5
.gitignore vendored
View File

@ -1,6 +1,3 @@
node_modules/
docs/
coverage/
ts/**/*.js
ts/**/*.js.map
.idea/
coverage/

36
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,36 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
release:
stage: release
environment: npmjs-com_registry
script:
- npmci publish
only:
- tags
tags:
- docker

2
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
export declare let isCi: () => boolean;
export declare let isTaggedCommit: () => boolean;

19
dist/index.js vendored
View File

@ -1,10 +1,13 @@
"use strict";
var SmartCiCheck = require("./smartci.check");
var SmartCiGet = require("./smartci.get");
var smartci = {
check: SmartCiCheck,
get: SmartCiGet
exports.isCi = function () {
if (process.env.CI == "true") {
return true;
}
else {
return false;
}
};
module.exports = smartci;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFPLFlBQVksV0FBVyxpQkFBaUIsQ0FBQyxDQUFDO0FBQ2pELElBQU8sVUFBVSxXQUFXLGVBQWUsQ0FBQyxDQUFDO0FBQzdDLElBQUksT0FBTyxHQUFHO0lBQ1YsS0FBSyxFQUFFLFlBQVk7SUFDbkIsR0FBRyxFQUFFLFVBQVU7Q0FDbEIsQ0FBQztBQUVGLGlCQUFTLE9BQU8sQ0FBQyIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCJ0eXBpbmdzL21haW4uZC50c1wiIC8+XG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0Y2kucGx1Z2luc1wiKTtcbmltcG9ydCBTbWFydENpQ2hlY2sgPSByZXF1aXJlKFwiLi9zbWFydGNpLmNoZWNrXCIpO1xuaW1wb3J0IFNtYXJ0Q2lHZXQgPSByZXF1aXJlKFwiLi9zbWFydGNpLmdldFwiKTtcbmxldCBzbWFydGNpID0ge1xuICAgIGNoZWNrOiBTbWFydENpQ2hlY2ssXG4gICAgZ2V0OiBTbWFydENpR2V0XG59O1xuXG5leHBvcnQgPSBzbWFydGNpO1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
exports.isTaggedCommit = () => {
return typeof process.env.CI_BUILD_TAG != "undefined";
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBR1csWUFBSSxHQUFHO0lBQ2QsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxFQUFFLElBQUksTUFBTSxDQUFDLENBQUEsQ0FBQztRQUN6QixNQUFNLENBQUMsSUFBSSxDQUFDO0lBQ2hCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLE1BQU0sQ0FBQyxLQUFLLENBQUM7SUFDakIsQ0FBQztBQUNMLENBQUMsQ0FBQztBQUVTLHNCQUFjLEdBQUc7SUFDeEIsTUFBTSxDQUFDLE9BQU8sT0FBTyxDQUFDLEdBQUcsQ0FBQyxZQUFZLElBQUksV0FBVyxDQUFDO0FBQzFELENBQUMsQ0FBQSJ9

20
dist/smartci.check.js vendored
View File

@ -1,20 +0,0 @@
/// <reference path="typings/main.d.ts" />
"use strict";
exports.isCi = function () {
if (process.env.CI == "true") {
return true;
}
else {
return false;
}
};
exports.isTaggedCommit = function () {
if (process.env.TRAVIS_TAG != "") {
return true;
}
else {
return false;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2kuY2hlY2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsMENBQTBDOztBQUkvQixZQUFJLEdBQUc7SUFDZCxFQUFFLENBQUEsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUUsSUFBSSxNQUFNLENBQUMsQ0FBQSxDQUFDO1FBQ3pCLE1BQU0sQ0FBQyxJQUFJLENBQUM7SUFDaEIsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osTUFBTSxDQUFDLEtBQUssQ0FBQztJQUNqQixDQUFDO0FBQ0wsQ0FBQyxDQUFDO0FBRVMsc0JBQWMsR0FBRztJQUN4QixFQUFFLENBQUEsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsSUFBSSxFQUFFLENBQUMsQ0FBQSxDQUFDO1FBQzdCLE1BQU0sQ0FBQyxJQUFJLENBQUM7SUFDaEIsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osTUFBTSxDQUFDLEtBQUssQ0FBQztJQUNqQixDQUFDO0FBQ0wsQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0Y2kuY2hlY2suanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwidHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0Y2kucGx1Z2luc1wiKTtcblxuZXhwb3J0IGxldCBpc0NpID0gZnVuY3Rpb24oKTpib29sZWFuIHtcbiAgICBpZihwcm9jZXNzLmVudi5DSSA9PSBcInRydWVcIil7XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG59O1xuXG5leHBvcnQgbGV0IGlzVGFnZ2VkQ29tbWl0ID0gZnVuY3Rpb24oKXtcbiAgICBpZihwcm9jZXNzLmVudi5UUkFWSVNfVEFHICE9IFwiXCIpe1xuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxufTtcblxuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

17
dist/smartci.get.js vendored
View File

@ -1,17 +0,0 @@
/// <reference path="typings/main.d.ts" />
"use strict";
exports.ciName = function () {
};
exports.jobNumberString = function () {
return process.env.TRAVIS_JOB_NUMBER;
};
exports.mainJobNumber = function () {
return parseInt(exports.jobNumberString());
};
exports.subJobNumber = function () {
var subJobRegex = /[0-9]*\.(.*)/;
var regexArray = subJobRegex.exec(exports.jobNumberString());
return parseInt(regexArray[1]);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2kuZ2V0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDBDQUEwQzs7QUFJL0IsY0FBTSxHQUFHO0FBRXBCLENBQUMsQ0FBQztBQUVTLHVCQUFlLEdBQUc7SUFDekIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsaUJBQWlCLENBQUM7QUFDekMsQ0FBQyxDQUFDO0FBRVMscUJBQWEsR0FBRztJQUN2QixNQUFNLENBQUMsUUFBUSxDQUFDLHVCQUFlLEVBQUUsQ0FBQyxDQUFDO0FBQ3ZDLENBQUMsQ0FBQztBQUVTLG9CQUFZLEdBQUc7SUFDdEIsSUFBSSxXQUFXLEdBQUcsY0FBYyxDQUFDO0lBQ2pDLElBQUksVUFBVSxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsdUJBQWUsRUFBRSxDQUFDLENBQUM7SUFDckQsTUFBTSxDQUFDLFFBQVEsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUNuQyxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRjaS5nZXQuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwidHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0Y2kucGx1Z2luc1wiKTtcblxuZXhwb3J0IGxldCBjaU5hbWUgPSBmdW5jdGlvbigpe1xuXG59O1xuXG5leHBvcnQgbGV0IGpvYk51bWJlclN0cmluZyA9IGZ1bmN0aW9uKCk6c3RyaW5nIHtcbiAgICByZXR1cm4gcHJvY2Vzcy5lbnYuVFJBVklTX0pPQl9OVU1CRVI7XG59O1xuXG5leHBvcnQgbGV0IG1haW5Kb2JOdW1iZXIgPSBmdW5jdGlvbigpOm51bWJlcntcbiAgICByZXR1cm4gcGFyc2VJbnQoam9iTnVtYmVyU3RyaW5nKCkpO1xufTtcblxuZXhwb3J0IGxldCBzdWJKb2JOdW1iZXIgPSBmdW5jdGlvbigpOm51bWJlciB7XG4gICAgbGV0IHN1YkpvYlJlZ2V4ID0gL1swLTldKlxcLiguKikvO1xuICAgIGxldCByZWdleEFycmF5ID0gc3ViSm9iUmVnZXguZXhlYyhqb2JOdW1iZXJTdHJpbmcoKSk7XG4gICAgcmV0dXJuIHBhcnNlSW50KHJlZ2V4QXJyYXlbMV0pO1xufTtcblxuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

2
dist/smartci.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import "typings-global";
export declare let path: any;

View File

@ -1,5 +1,4 @@
"use strict";
/// <reference path="typings/main.d.ts" />
require("typings-global");
exports.path = require("path");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0Y2kucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMENBQTBDO0FBQy9CLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRjaS5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cInR5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjaS5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjaS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDYixZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDIn0=

View File

@ -20,10 +20,12 @@
},
"homepage": "https://github.com/pushrocks/smartci",
"dependencies": {
"beautylog": "^3.1.2"
"beautylog": "^5.0.18",
"typings-global": "^1.0.6"
},
"devDependencies": {
"npmts": "^3.6.3",
"should": "^8.3.0"
"npmts-g": "^5.2.8",
"should": "^10.0.0",
"typings-test": "^1.0.1"
}
}

1
test/test.d.ts vendored Normal file
View File

@ -0,0 +1 @@
import "typings-test";

View File

@ -1,42 +1,25 @@
/// <reference path="../ts/typings/main.d.ts" />
"use strict";
require("typings-test");
var smartci = require("../dist/index.js");
var should = require("should");
process.env.TRAVIS_JOB_NUMBER = "180.3";
process.env.TRAVIS_TAG = "";
process.env.CI = "true";
describe("smartci", function () {
describe("check", function () {
describe(".isCi", function () {
it("should state if we are in a CI environment", function () {
smartci.check.isCi().should.be.true();
smartci.isCi().should.be.true();
process.env.CI = "false";
smartci.check.isCi().should.be.false();
smartci.isCi().should.be.false();
});
});
describe(".isTaggedCommit", function () {
it("should state if we are dealing with a tagged commit", function () {
smartci.check.isTaggedCommit().should.be.false();
process.env.TRAVIS_TAG = "v0.3.1";
smartci.check.isTaggedCommit().should.be.true();
});
});
});
describe("get", function () {
describe(".jobNumberString", function () {
it("should get the correct job number", function () {
smartci.get.jobNumberString().should.equal("180.3");
});
});
describe(".mainJobNumber", function () {
it("should get the correct main job number", function () {
smartci.get.mainJobNumber().should.equal(180);
});
});
describe(".subJobNumber", function () {
it("should get the correct sub job number", function () {
smartci.get.subJobNumber().should.equal(3);
smartci.isTaggedCommit().should.be.false();
process.env.CI_BUILD_TAG = "3.1.2";
smartci.isTaggedCommit().should.be.true();
});
});
});
});
//# sourceMappingURL=test.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLGtCQUFrQixDQUFDLENBQUM7QUFDMUMsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBRS9CLE9BQU8sQ0FBQyxHQUFHLENBQUMsaUJBQWlCLEdBQUcsT0FBTyxDQUFDO0FBQ3hDLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFBRSxHQUFHLE1BQU0sQ0FBQztBQUV4QixRQUFRLENBQUMsU0FBUyxFQUFDO0lBQ2YsUUFBUSxDQUFDLE9BQU8sRUFBQztRQUNiLFFBQVEsQ0FBQyxPQUFPLEVBQUM7WUFDYixFQUFFLENBQUMsNENBQTRDLEVBQUM7Z0JBQzVDLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxDQUFDO2dCQUNoQyxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUUsR0FBRyxPQUFPLENBQUM7Z0JBQ3pCLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDO1lBQ3JDLENBQUMsQ0FBQyxDQUFDO1FBQ1AsQ0FBQyxDQUFDLENBQUM7UUFDSCxRQUFRLENBQUMsaUJBQWlCLEVBQUM7WUFDdkIsRUFBRSxDQUFDLHFEQUFxRCxFQUFDO2dCQUNyRCxPQUFPLENBQUMsY0FBYyxFQUFFLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxLQUFLLEVBQUUsQ0FBQztnQkFDM0MsT0FBTyxDQUFDLEdBQUcsQ0FBQyxZQUFZLEdBQUcsT0FBTyxDQUFDO2dCQUNuQyxPQUFPLENBQUMsY0FBYyxFQUFFLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztZQUM5QyxDQUFDLENBQUMsQ0FBQTtRQUNOLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyJ9

View File

@ -1,44 +1,25 @@
/// <reference path="../ts/typings/main.d.ts" />
import "typings-test";
var smartci = require("../dist/index.js");
var should = require("should");
process.env.TRAVIS_JOB_NUMBER = "180.3";
process.env.TRAVIS_TAG = "";
process.env.CI = "true";
describe("smartci",function(){
describe("check",function(){
describe(".isCi",function(){
it("should state if we are in a CI environment",function(){
smartci.check.isCi().should.be.true();
smartci.isCi().should.be.true();
process.env.CI = "false";
smartci.check.isCi().should.be.false();
smartci.isCi().should.be.false();
});
});
describe(".isTaggedCommit",function(){
it("should state if we are dealing with a tagged commit",function(){
smartci.check.isTaggedCommit().should.be.false();
process.env.TRAVIS_TAG = "v0.3.1";
smartci.check.isTaggedCommit().should.be.true();
smartci.isTaggedCommit().should.be.false();
process.env.CI_BUILD_TAG = "3.1.2";
smartci.isTaggedCommit().should.be.true();
})
});
});
describe("get",function(){
describe(".jobNumberString",function(){
it("should get the correct job number",function(){
smartci.get.jobNumberString().should.equal("180.3");
});
});
describe(".mainJobNumber",function(){
it("should get the correct main job number",function(){
smartci.get.mainJobNumber().should.equal(180);
})
});
describe(".subJobNumber",function(){
it("should get the correct sub job number",function(){
smartci.get.subJobNumber().should.equal(3);
})
});
});
});

View File

@ -1,10 +1,14 @@
/// <reference path="typings/main.d.ts" />
import plugins = require("./smartci.plugins");
import SmartCiCheck = require("./smartci.check");
import SmartCiGet = require("./smartci.get");
let smartci = {
check: SmartCiCheck,
get: SmartCiGet
export let isCi = function():boolean {
if(process.env.CI == "true"){
return true;
} else {
return false;
}
};
export = smartci;
export let isTaggedCommit = () => {
return typeof process.env.CI_BUILD_TAG != "undefined";
}

View File

@ -1,20 +0,0 @@
/// <reference path="typings/main.d.ts" />
import plugins = require("./smartci.plugins");
export let isCi = function():boolean {
if(process.env.CI == "true"){
return true;
} else {
return false;
}
};
export let isTaggedCommit = function(){
if(process.env.TRAVIS_TAG != ""){
return true;
} else {
return false;
}
};

View File

@ -1,22 +0,0 @@
/// <reference path="typings/main.d.ts" />
import plugins = require("./smartci.plugins");
export let ciName = function(){
};
export let jobNumberString = function():string {
return process.env.TRAVIS_JOB_NUMBER;
};
export let mainJobNumber = function():number{
return parseInt(jobNumberString());
};
export let subJobNumber = function():number {
let subJobRegex = /[0-9]*\.(.*)/;
let regexArray = subJobRegex.exec(jobNumberString());
return parseInt(regexArray[1]);
};

View File

@ -1,2 +1,2 @@
/// <reference path="typings/main.d.ts" />
import "typings-global";
export let path = require("path");

View File

@ -1,12 +0,0 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
}
}
}

View File

@ -1,7 +0,0 @@
{
"version": false,
"ambientDependencies": {
"mocha": "registry:dt/mocha#2.2.5+20160317120654",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#efa0c1196d7280640e624ac1e7fa604502e7bd63"
}
}

View File

@ -1,2 +0,0 @@
/// <reference path="browser/ambient/mocha/index.d.ts" />
/// <reference path="browser/ambient/node/index.d.ts" />

View File

@ -1,238 +0,0 @@
// Generated by typings
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/mocha/mocha.d.ts
// Type definitions for mocha 2.2.5
// Project: http://mochajs.org/
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface MochaSetupOptions {
//milliseconds to wait before considering a test slow
slow?: number;
// timeout in milliseconds
timeout?: number;
// ui name "bdd", "tdd", "exports" etc
ui?: string;
//array of accepted globals
globals?: any[];
// reporter instance (function or string), defaults to `mocha.reporters.Spec`
reporter?: any;
// bail on the first test failure
bail?: boolean;
// ignore global leaks
ignoreLeaks?: boolean;
// grep string or regexp to filter tests with
grep?: any;
}
interface MochaDone {
(error?: Error): void;
}
declare var mocha: Mocha;
declare var describe: Mocha.IContextDefinition;
declare var xdescribe: Mocha.IContextDefinition;
// alias for `describe`
declare var context: Mocha.IContextDefinition;
// alias for `describe`
declare var suite: Mocha.IContextDefinition;
declare var it: Mocha.ITestDefinition;
declare var xit: Mocha.ITestDefinition;
// alias for `it`
declare var test: Mocha.ITestDefinition;
declare function before(action: () => void): void;
declare function before(action: (done: MochaDone) => void): void;
declare function before(description: string, action: () => void): void;
declare function before(description: string, action: (done: MochaDone) => void): void;
declare function setup(action: () => void): void;
declare function setup(action: (done: MochaDone) => void): void;
declare function after(action: () => void): void;
declare function after(action: (done: MochaDone) => void): void;
declare function after(description: string, action: () => void): void;
declare function after(description: string, action: (done: MochaDone) => void): void;
declare function teardown(action: () => void): void;
declare function teardown(action: (done: MochaDone) => void): void;
declare function beforeEach(action: () => void): void;
declare function beforeEach(action: (done: MochaDone) => void): void;
declare function beforeEach(description: string, action: () => void): void;
declare function beforeEach(description: string, action: (done: MochaDone) => void): void;
declare function suiteSetup(action: () => void): void;
declare function suiteSetup(action: (done: MochaDone) => void): void;
declare function afterEach(action: () => void): void;
declare function afterEach(action: (done: MochaDone) => void): void;
declare function afterEach(description: string, action: () => void): void;
declare function afterEach(description: string, action: (done: MochaDone) => void): void;
declare function suiteTeardown(action: () => void): void;
declare function suiteTeardown(action: (done: MochaDone) => void): void;
declare class Mocha {
constructor(options?: {
grep?: RegExp;
ui?: string;
reporter?: string;
timeout?: number;
bail?: boolean;
});
/** Setup mocha with the given options. */
setup(options: MochaSetupOptions): Mocha;
bail(value?: boolean): Mocha;
addFile(file: string): Mocha;
/** Sets reporter by name, defaults to "spec". */
reporter(name: string): Mocha;
/** Sets reporter constructor, defaults to mocha.reporters.Spec. */
reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha;
ui(value: string): Mocha;
grep(value: string): Mocha;
grep(value: RegExp): Mocha;
invert(): Mocha;
ignoreLeaks(value: boolean): Mocha;
checkLeaks(): Mocha;
/**
* Function to allow assertion libraries to throw errors directly into mocha.
* This is useful when running tests in a browser because window.onerror will
* only receive the 'message' attribute of the Error.
*/
throwError(error: Error): void;
/** Enables growl support. */
growl(): Mocha;
globals(value: string): Mocha;
globals(values: string[]): Mocha;
useColors(value: boolean): Mocha;
useInlineDiffs(value: boolean): Mocha;
timeout(value: number): Mocha;
slow(value: number): Mocha;
enableTimeouts(value: boolean): Mocha;
asyncOnly(value: boolean): Mocha;
noHighlighting(value: boolean): Mocha;
/** Runs tests and invokes `onComplete()` when finished. */
run(onComplete?: (failures: number) => void): Mocha.IRunner;
}
// merge the Mocha class declaration with a module
declare namespace Mocha {
/** Partial interface for Mocha's `Runnable` class. */
interface IRunnable {
title: string;
fn: Function;
async: boolean;
sync: boolean;
timedOut: boolean;
}
/** Partial interface for Mocha's `Suite` class. */
interface ISuite {
parent: ISuite;
title: string;
fullTitle(): string;
}
/** Partial interface for Mocha's `Test` class. */
interface ITest extends IRunnable {
parent: ISuite;
pending: boolean;
fullTitle(): string;
}
/** Partial interface for Mocha's `Runner` class. */
interface IRunner {}
interface IContextDefinition {
(description: string, spec: () => void): ISuite;
only(description: string, spec: () => void): ISuite;
skip(description: string, spec: () => void): void;
timeout(ms: number): void;
}
interface ITestDefinition {
(expectation: string, assertion?: () => void): ITest;
(expectation: string, assertion?: (done: MochaDone) => void): ITest;
only(expectation: string, assertion?: () => void): ITest;
only(expectation: string, assertion?: (done: MochaDone) => void): ITest;
skip(expectation: string, assertion?: () => void): void;
skip(expectation: string, assertion?: (done: MochaDone) => void): void;
timeout(ms: number): void;
}
export module reporters {
export class Base {
stats: {
suites: number;
tests: number;
passes: number;
pending: number;
failures: number;
};
constructor(runner: IRunner);
}
export class Doc extends Base {}
export class Dot extends Base {}
export class HTML extends Base {}
export class HTMLCov extends Base {}
export class JSON extends Base {}
export class JSONCov extends Base {}
export class JSONStream extends Base {}
export class Landing extends Base {}
export class List extends Base {}
export class Markdown extends Base {}
export class Min extends Base {}
export class Nyan extends Base {}
export class Progress extends Base {
/**
* @param options.open String used to indicate the start of the progress bar.
* @param options.complete String used to indicate a complete test on the progress bar.
* @param options.incomplete String used to indicate an incomplete test on the progress bar.
* @param options.close String used to indicate the end of the progress bar.
*/
constructor(runner: IRunner, options?: {
open?: string;
complete?: string;
incomplete?: string;
close?: string;
});
}
export class Spec extends Base {}
export class TAP extends Base {}
export class XUnit extends Base {
constructor(runner: IRunner, options?: any);
}
}
}
declare module "mocha" {
export = Mocha;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +0,0 @@
/// <reference path="main/ambient/mocha/index.d.ts" />
/// <reference path="main/ambient/node/index.d.ts" />

View File

@ -1,238 +0,0 @@
// Generated by typings
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/mocha/mocha.d.ts
// Type definitions for mocha 2.2.5
// Project: http://mochajs.org/
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface MochaSetupOptions {
//milliseconds to wait before considering a test slow
slow?: number;
// timeout in milliseconds
timeout?: number;
// ui name "bdd", "tdd", "exports" etc
ui?: string;
//array of accepted globals
globals?: any[];
// reporter instance (function or string), defaults to `mocha.reporters.Spec`
reporter?: any;
// bail on the first test failure
bail?: boolean;
// ignore global leaks
ignoreLeaks?: boolean;
// grep string or regexp to filter tests with
grep?: any;
}
interface MochaDone {
(error?: Error): void;
}
declare var mocha: Mocha;
declare var describe: Mocha.IContextDefinition;
declare var xdescribe: Mocha.IContextDefinition;
// alias for `describe`
declare var context: Mocha.IContextDefinition;
// alias for `describe`
declare var suite: Mocha.IContextDefinition;
declare var it: Mocha.ITestDefinition;
declare var xit: Mocha.ITestDefinition;
// alias for `it`
declare var test: Mocha.ITestDefinition;
declare function before(action: () => void): void;
declare function before(action: (done: MochaDone) => void): void;
declare function before(description: string, action: () => void): void;
declare function before(description: string, action: (done: MochaDone) => void): void;
declare function setup(action: () => void): void;
declare function setup(action: (done: MochaDone) => void): void;
declare function after(action: () => void): void;
declare function after(action: (done: MochaDone) => void): void;
declare function after(description: string, action: () => void): void;
declare function after(description: string, action: (done: MochaDone) => void): void;
declare function teardown(action: () => void): void;
declare function teardown(action: (done: MochaDone) => void): void;
declare function beforeEach(action: () => void): void;
declare function beforeEach(action: (done: MochaDone) => void): void;
declare function beforeEach(description: string, action: () => void): void;
declare function beforeEach(description: string, action: (done: MochaDone) => void): void;
declare function suiteSetup(action: () => void): void;
declare function suiteSetup(action: (done: MochaDone) => void): void;
declare function afterEach(action: () => void): void;
declare function afterEach(action: (done: MochaDone) => void): void;
declare function afterEach(description: string, action: () => void): void;
declare function afterEach(description: string, action: (done: MochaDone) => void): void;
declare function suiteTeardown(action: () => void): void;
declare function suiteTeardown(action: (done: MochaDone) => void): void;
declare class Mocha {
constructor(options?: {
grep?: RegExp;
ui?: string;
reporter?: string;
timeout?: number;
bail?: boolean;
});
/** Setup mocha with the given options. */
setup(options: MochaSetupOptions): Mocha;
bail(value?: boolean): Mocha;
addFile(file: string): Mocha;
/** Sets reporter by name, defaults to "spec". */
reporter(name: string): Mocha;
/** Sets reporter constructor, defaults to mocha.reporters.Spec. */
reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha;
ui(value: string): Mocha;
grep(value: string): Mocha;
grep(value: RegExp): Mocha;
invert(): Mocha;
ignoreLeaks(value: boolean): Mocha;
checkLeaks(): Mocha;
/**
* Function to allow assertion libraries to throw errors directly into mocha.
* This is useful when running tests in a browser because window.onerror will
* only receive the 'message' attribute of the Error.
*/
throwError(error: Error): void;
/** Enables growl support. */
growl(): Mocha;
globals(value: string): Mocha;
globals(values: string[]): Mocha;
useColors(value: boolean): Mocha;
useInlineDiffs(value: boolean): Mocha;
timeout(value: number): Mocha;
slow(value: number): Mocha;
enableTimeouts(value: boolean): Mocha;
asyncOnly(value: boolean): Mocha;
noHighlighting(value: boolean): Mocha;
/** Runs tests and invokes `onComplete()` when finished. */
run(onComplete?: (failures: number) => void): Mocha.IRunner;
}
// merge the Mocha class declaration with a module
declare namespace Mocha {
/** Partial interface for Mocha's `Runnable` class. */
interface IRunnable {
title: string;
fn: Function;
async: boolean;
sync: boolean;
timedOut: boolean;
}
/** Partial interface for Mocha's `Suite` class. */
interface ISuite {
parent: ISuite;
title: string;
fullTitle(): string;
}
/** Partial interface for Mocha's `Test` class. */
interface ITest extends IRunnable {
parent: ISuite;
pending: boolean;
fullTitle(): string;
}
/** Partial interface for Mocha's `Runner` class. */
interface IRunner {}
interface IContextDefinition {
(description: string, spec: () => void): ISuite;
only(description: string, spec: () => void): ISuite;
skip(description: string, spec: () => void): void;
timeout(ms: number): void;
}
interface ITestDefinition {
(expectation: string, assertion?: () => void): ITest;
(expectation: string, assertion?: (done: MochaDone) => void): ITest;
only(expectation: string, assertion?: () => void): ITest;
only(expectation: string, assertion?: (done: MochaDone) => void): ITest;
skip(expectation: string, assertion?: () => void): void;
skip(expectation: string, assertion?: (done: MochaDone) => void): void;
timeout(ms: number): void;
}
export module reporters {
export class Base {
stats: {
suites: number;
tests: number;
passes: number;
pending: number;
failures: number;
};
constructor(runner: IRunner);
}
export class Doc extends Base {}
export class Dot extends Base {}
export class HTML extends Base {}
export class HTMLCov extends Base {}
export class JSON extends Base {}
export class JSONCov extends Base {}
export class JSONStream extends Base {}
export class Landing extends Base {}
export class List extends Base {}
export class Markdown extends Base {}
export class Min extends Base {}
export class Nyan extends Base {}
export class Progress extends Base {
/**
* @param options.open String used to indicate the start of the progress bar.
* @param options.complete String used to indicate a complete test on the progress bar.
* @param options.incomplete String used to indicate an incomplete test on the progress bar.
* @param options.close String used to indicate the end of the progress bar.
*/
constructor(runner: IRunner, options?: {
open?: string;
complete?: string;
incomplete?: string;
close?: string;
});
}
export class Spec extends Base {}
export class TAP extends Base {}
export class XUnit extends Base {
constructor(runner: IRunner, options?: any);
}
}
}
declare module "mocha" {
export = Mocha;
}

File diff suppressed because it is too large Load Diff