Skip to content

Commit a8ae59b

Browse files
Update for TypeScript 2.0
1 parent 5fd5572 commit a8ae59b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1098
-863
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# JavaScript and TypeScript
55
lib/
66
test/lib/
7-
typings/
87

98
# Documentation
109
docs/

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ node_js:
44
- 6
55
- 5
66
- 4
7+
- 4.0.0
78
install:
89
- npm install -g gulp
9-
- npm install -g typings
1010
- npm install
11-
- typings install
1211
script: gulp

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.0 ##
2+
3+
* Add null and undefined in type declarations
4+
15
## 0.1.1 ##
26

37
* Re-write in TypeScript

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# xmlcreate #
22

33
[![Build Status](https://travis-ci.org/michaelkourlas/node-xmlcreate.svg?branch=master)](https://travis-ci.org/michaelkourlas/node-xmlcreate)
4+
[![npm version](https://badge.fury.io/js/xmlcreate.svg)](https://badge.fury.io/js/xmlcreate)
45

56
## Overview ##
67

gulpfile.js

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
"use strict";
1818

1919
var doc = require("gulp-typedoc");
20-
var filter = require("gulp-filter");
21-
var fs = require("fs");
2220
var gulp = require("gulp");
2321
var merge2 = require("merge2");
2422
var mocha = require("gulp-mocha");
@@ -28,66 +26,54 @@ var tslint = require("gulp-tslint");
2826

2927
gulp.task("default", ["prod", "test-prod", "docs"]);
3028

31-
var tsLibOptions = {
32-
"module": "commonjs",
33-
"target": "es5",
34-
"noImplicitAny": true,
35-
"noImplicitReturns": true,
36-
"declaration": true
37-
};
29+
var tsProject = ts.createProject("tsconfig.json");
3830
gulp.task("prod", function() {
39-
var tsResult = gulp.src("src/**/*.ts")
40-
.pipe(tslint({formatter: "verbose"}))
41-
.pipe(tslint.report())
42-
.pipe(ts(tsLibOptions));
31+
var tsResult = tsProject.src()
32+
.pipe(tslint())
33+
.pipe(tslint.report())
34+
.pipe(tsProject(ts.reporter.longReporter()));
4335
return merge2([tsResult.js
4436
.pipe(gulp.dest("lib")),
4537
tsResult.dts
4638
.pipe(gulp.dest("lib"))]);
4739
});
4840
gulp.task("dev", function() {
49-
var tsResult = gulp.src("src/**/*.ts")
50-
.pipe(tslint({formatter: "verbose"}))
51-
.pipe(tslint.report())
52-
.pipe(sourcemaps.init())
53-
.pipe(ts(tsLibOptions));
41+
var tsResult = tsProject.src()
42+
.pipe(tslint())
43+
.pipe(tslint.report())
44+
.pipe(sourcemaps.init())
45+
.pipe(tsProject(ts.reporter.longReporter()));
5446
return merge2([tsResult.js
5547
.pipe(sourcemaps.write())
5648
.pipe(gulp.dest("lib")),
5749
tsResult.dts
5850
.pipe(gulp.dest("lib"))]);
5951
});
6052

53+
var testTsProject = ts.createProject("test/tsconfig.json");
54+
var test = function() {
55+
return testTsProject.src()
56+
.pipe(tslint())
57+
.pipe(tslint.report())
58+
.pipe(sourcemaps.init())
59+
.pipe(testTsProject(ts.reporter.longReporter()))
60+
.pipe(sourcemaps.write())
61+
.pipe(gulp.dest("test/lib"))
62+
.pipe(mocha());
63+
};
64+
gulp.task("test", ["prod"], test);
65+
gulp.task("test-prod", ["prod"], test);
66+
gulp.task("test-dev", ["dev"], test);
67+
6168
var docOptions = {
69+
mode: "file",
6270
module: "commonjs",
63-
target: "es5",
6471
out: "docs",
65-
mode: "file"
72+
target: "es5",
73+
// TODO: Remove this option once TypeDoc supports TypeScript 2.0
74+
ignoreCompilerErrors: true
6675
};
6776
gulp.task("docs", function() {
6877
return gulp.src("src")
6978
.pipe(doc(docOptions));
7079
});
71-
72-
var tsTestOptions = {
73-
"module": "commonjs",
74-
"target": "es5",
75-
"noImplicitAny": true,
76-
"noImplicitReturns": true
77-
};
78-
var dtsFilter = filter(["**/*.ts", "!**/*.d.ts"], {restore: true});
79-
var test = function() {
80-
return gulp.src(["test/src/**/*.ts", "typings/index.d.ts"])
81-
.pipe(dtsFilter)
82-
.pipe(tslint({formatter: "verbose"}))
83-
.pipe(tslint.report())
84-
.pipe(dtsFilter.restore)
85-
.pipe(sourcemaps.init())
86-
.pipe(ts(tsTestOptions))
87-
.pipe(sourcemaps.write())
88-
.pipe(gulp.dest("test/lib"))
89-
.pipe(mocha());
90-
};
91-
gulp.task("test", ["prod"], test);
92-
gulp.task("test-prod", ["prod"], test);
93-
gulp.task("test-dev", ["dev"], test);

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xmlcreate",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Simple XML builder for Node.js",
55
"keywords": [
66
"build",
@@ -29,18 +29,22 @@
2929
"url": "git://github.com/michaelkourlas/node-xmlcreate.git"
3030
},
3131
"devDependencies": {
32+
"@types/chai": "^3.4.34",
33+
"@types/mocha": "^2.2.32",
3234
"chai": "^3.5.0",
3335
"gulp": "^3.9.1",
34-
"gulp-filter": "^4.0.0",
3536
"gulp-mocha": "^3.0.1",
3637
"gulp-sourcemaps": "^1.6.0",
37-
"gulp-tslint": "^6.1.1",
38+
"gulp-tslint": "^6.1.2",
3839
"gulp-typedoc": "^2.0.0",
39-
"gulp-typescript": "^2.13.6",
40+
"gulp-typescript": "^3.0.1",
4041
"merge2": "^1.0.2",
41-
"mocha": "^3.0.2",
42+
"mocha": "^3.1.0",
4243
"tslint": "^3.15.1",
4344
"typedoc": "^0.4.5",
44-
"typings": "^1.3.3"
45+
"typescript": "^2.0.3"
46+
},
47+
"engines": {
48+
"node": ">=4.0.0"
4549
}
4650
}

src/escape.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
/**
1818
* Replaces ampersands (&) with the appropriate XML character reference.
1919
*
20-
* @param {string} str The string to escape.
20+
* @param str The string to escape.
2121
*
22-
* @returns {string} A copy of the specified string with ampersands escaped.
22+
* @returns A copy of the specified string with ampersands escaped.
2323
*
2424
* @private
2525
*/
@@ -31,10 +31,9 @@ export function escapeAmpersands(str: string): string {
3131
* Replaces left angle brackets (<) with the appropriate XML character
3232
* reference.
3333
*
34-
* @param {string} str The string to escape.
34+
* @param str The string to escape.
3535
*
36-
* @returns {string} A copy of the specified string with left angle brackets
37-
* escaped.
36+
* @returns A copy of the specified string with left angle brackets escaped.
3837
*
3938
* @private
4039
*/
@@ -45,9 +44,9 @@ export function escapeLeftAngleBrackets(str: string): string {
4544
/**
4645
* Replaces single quotes (") with the appropriate XML character reference.
4746
*
48-
* @param {string} str The string to escape.
47+
* @param str The string to escape.
4948
*
50-
* @returns {string} A copy of the specified string with single quotes escaped.
49+
* @returns A copy of the specified string with single quotes escaped.
5150
*
5251
* @private
5352
*/
@@ -58,9 +57,9 @@ export function escapeSingleQuotes(str: string): string {
5857
/**
5958
* Replaces double quotes (") with the appropriate XML character reference.
6059
*
61-
* @param {string} str The string to escape.
60+
* @param str The string to escape.
6261
*
63-
* @returns {string} A copy of the specified string with double quotes escaped.
62+
* @returns A copy of the specified string with double quotes escaped.
6463
*
6564
* @private
6665
*/

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export {
4242
/**
4343
* Creates a new XML document.
4444
*
45-
* @param {string} root The name of the root element of the document.
45+
* @param root The name of the root element of the document.
4646
*
47-
* @returns {XmlDocument} The new XML document.
47+
* @returns The new XML document.
4848
*/
4949
export function document(root: string): XmlDocument {
5050
return new XmlDocument(root);

0 commit comments

Comments
 (0)