Skip to content

Commit debf3ad

Browse files
Update dependencies, update tests, remove explicit engines requirement, other changes
1 parent f37daf1 commit debf3ad

File tree

12 files changed

+248
-227
lines changed

12 files changed

+248
-227
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ node_js:
44
- 6
55
- 5
66
- 4
7-
- 4.0.0
87
install:
98
- npm install -g gulp
109
- npm install

CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## 2.1.0 ##
1+
## 3.0.0 ##
22

3+
* Bug fixes
34
* Add null and undefined in type declarations
5+
* Remove explicit engines requirement
46

57
## 2.0.2 ##
68

NOTICE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
js2xmlparser
2-
Copyright (C) 2016 Michael Kourlas
2+
Copyright (C) 2016-2017 Michael Kourlas
33

44
## Apache License, version 2.0 ##
55

66
The following components are provided under the [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0):
77

88
xmlcreate
9-
Copyright (C) 2016 Michael Kourlas
9+
Copyright (C) 2016-2017 Michael Kourlas

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ includes source maps.
6666

6767
## Usage ##
6868

69-
The documentation for the current version is available [here](http://www.kourlas.com/node-js2xmlparser/docs/2.0.2/).
69+
The documentation for the current version is available [here](http://www.kourlas.com/node-js2xmlparser/docs/3.0.0/).
7070

7171
You can also build the documentation using gulp:
7272

gulpfile.js

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016 Michael Kourlas
2+
* Copyright (C) 2016-2017 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,47 +16,77 @@
1616

1717
"use strict";
1818

19-
var doc = require("gulp-typedoc");
19+
var del = require("del");
20+
var typedoc = require("gulp-typedoc");
2021
var gulp = require("gulp");
2122
var merge2 = require("merge2");
2223
var mocha = require("gulp-mocha");
2324
var sourcemaps = require('gulp-sourcemaps');
24-
var ts = require("gulp-typescript");
25+
var typescript = require("gulp-typescript");
2526
var tslint = require("gulp-tslint");
2627

2728
gulp.task("default", ["prod", "test-prod", "docs"]);
2829

29-
var tsProject = ts.createProject("tsconfig.json");
30-
gulp.task("prod", function() {
30+
gulp.task("clean", function() {
31+
return del("lib");
32+
});
33+
34+
gulp.task("clean-docs", function() {
35+
return del("docs");
36+
});
37+
38+
var tsProject = typescript.createProject("tsconfig.json");
39+
gulp.task("prod", ["clean"], function() {
3140
var tsResult = tsProject.src()
3241
.pipe(tslint())
3342
.pipe(tslint.report())
34-
.pipe(tsProject(ts.reporter.longReporter()));
43+
.pipe(tsProject())
44+
.on("error", function() {
45+
this.on("finish", function() {
46+
// Commented out pending resolution
47+
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14324
48+
// process.exit(1);
49+
});
50+
});
3551
return merge2([tsResult.js
3652
.pipe(gulp.dest("lib")),
3753
tsResult.dts
3854
.pipe(gulp.dest("lib"))]);
3955
});
40-
gulp.task("dev", function() {
56+
gulp.task("dev", ["clean"], function() {
4157
var tsResult = tsProject.src()
4258
.pipe(tslint())
4359
.pipe(tslint.report())
4460
.pipe(sourcemaps.init())
45-
.pipe(tsProject(ts.reporter.longReporter()));
61+
.pipe(tsProject())
62+
.on("error", function() {
63+
this.on("finish", function() {
64+
// Commented out pending resolution
65+
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14324
66+
// process.exit(1);
67+
});
68+
});
4669
return merge2([tsResult.js
4770
.pipe(sourcemaps.write())
4871
.pipe(gulp.dest("lib")),
4972
tsResult.dts
5073
.pipe(gulp.dest("lib"))]);
5174
});
5275

53-
var testTsProject = ts.createProject("test/tsconfig.json");
76+
var testTsProject = typescript.createProject("test/tsconfig.json");
5477
var test = function() {
5578
return testTsProject.src()
5679
.pipe(tslint())
5780
.pipe(tslint.report())
5881
.pipe(sourcemaps.init())
59-
.pipe(testTsProject(ts.reporter.longReporter()))
82+
.pipe(testTsProject())
83+
.on("error", function() {
84+
this.on("finish", function() {
85+
// Commented out pending resolution
86+
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14324
87+
// process.exit(1);
88+
});
89+
})
6090
.pipe(sourcemaps.write())
6191
.pipe(gulp.dest("test/lib"))
6292
.pipe(mocha());
@@ -69,11 +99,9 @@ var docOptions = {
6999
mode: "file",
70100
module: "commonjs",
71101
out: "docs",
72-
target: "es5",
73-
// TODO: Remove this option once TypeDoc supports TypeScript 2.0
74-
ignoreCompilerErrors: true
102+
target: "es5"
75103
};
76-
gulp.task("docs", function() {
104+
gulp.task("docs", ["prod", "clean-docs"], function() {
77105
return gulp.src("src")
78-
.pipe(doc(docOptions));
106+
.pipe(typedoc(docOptions));
79107
});

package.json

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js2xmlparser",
3-
"version": "2.1.0",
3+
"version": "3.0.0",
44
"description": "Parses JavaScript objects into XML",
55
"keywords": [
66
"convert",
@@ -35,25 +35,23 @@
3535
"url": "git://github.com/michaelkourlas/node-js2xmlparser.git"
3636
},
3737
"dependencies": {
38-
"xmlcreate": "^0.1.1"
38+
"xmlcreate": "^1.0.1"
3939
},
4040
"devDependencies": {
41-
"@types/chai": "^3.4.34",
42-
"@types/mocha": "^2.2.32",
41+
"@types/chai": "^3.4.35",
42+
"@types/mocha": "^2.2.39",
4343
"chai": "^3.5.0",
44+
"del": "^2.2.2",
4445
"gulp": "^3.9.1",
45-
"gulp-mocha": "^3.0.1",
46-
"gulp-sourcemaps": "^1.6.0",
47-
"gulp-tslint": "^6.1.2",
48-
"gulp-typedoc": "^2.0.0",
49-
"gulp-typescript": "^3.0.1",
50-
"merge2": "^1.0.2",
51-
"mocha": "^3.1.0",
52-
"tslint": "^3.15.1",
53-
"typedoc": "^0.4.5",
54-
"typescript": "^2.0.3"
55-
},
56-
"engines": {
57-
"node": ">=4.0.0"
46+
"gulp-mocha": "^4.0.1",
47+
"gulp-sourcemaps": "^2.4.1",
48+
"gulp-tslint": "^7.1.0",
49+
"gulp-typedoc": "^2.0.2",
50+
"gulp-typescript": "^3.1.5",
51+
"merge2": "^1.0.3",
52+
"mocha": "^3.2.0",
53+
"tslint": "^4.4.2",
54+
"typedoc": "^0.5.7",
55+
"typescript": "^2.1.6"
5856
}
5957
}

src/main.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2016 Michael Kourlas
2+
* Copyright (C) 2016-2017 Michael Kourlas
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
16+
import {XmlAttribute, XmlDocument, XmlElement} from "xmlcreate";
1717
import {IOptions, Options} from "./options";
1818
import {
1919
isArray,
@@ -26,7 +26,6 @@ import {
2626
isUndefined,
2727
stringify
2828
} from "./utils";
29-
import {XmlAttribute, XmlDocument, XmlElement} from "xmlcreate";
3029

3130
/**
3231
* Parses a string into XML.
@@ -48,17 +47,21 @@ function parseString(str: string, parentElement: XmlAttribute | XmlElement,
4847
|| options.cdataKeys.indexOf("*") !== -1;
4948
};
5049

51-
if (parentElement instanceof XmlElement && requiresCdata(str)) {
52-
const cdataStrs = str.split("]]>");
53-
for (let i = 0; i < cdataStrs.length; i++) {
54-
if (requiresCdata(cdataStrs[i])) {
55-
parentElement.cdata(cdataStrs[i]);
56-
} else {
57-
parentElement.text(cdataStrs[i]);
58-
}
59-
if (i < cdataStrs.length - 1) {
60-
parentElement.text("]]>");
50+
if (parentElement instanceof XmlElement) {
51+
if (requiresCdata(str)) {
52+
const cdataStrs = str.split("]]>");
53+
for (let i = 0; i < cdataStrs.length; i++) {
54+
if (requiresCdata(cdataStrs[i])) {
55+
parentElement.cdata(cdataStrs[i]);
56+
} else {
57+
parentElement.charData(cdataStrs[i]);
58+
}
59+
if (i < cdataStrs.length - 1) {
60+
parentElement.charData("]]>");
61+
}
6162
}
63+
} else {
64+
parentElement.charData(str);
6265
}
6366
} else {
6467
parentElement.text(str);
@@ -274,7 +277,7 @@ function parseToDocument(root: string, value: any,
274277
if (options.dtd.include) {
275278
document.dtd(options.dtd.name!, options.dtd.sysId, options.dtd.pubId);
276279
}
277-
parseValue(root, value, <XmlElement> document.root(), options);
280+
parseValue(root, value, document.root() as XmlElement, options);
278281
return document;
279282
}
280283

0 commit comments

Comments
 (0)