Commit e6786f47 authored by Fred Chasen's avatar Fred Chasen
Browse files

Return to latest release for vivliostyle.js, xhtml testing

parent a247cacf
...@@ -36,3 +36,4 @@ test/temp ...@@ -36,3 +36,4 @@ test/temp
# lib # lib
samples samples
test/output/*
...@@ -70,7 +70,12 @@ npm -g gulp ...@@ -70,7 +70,12 @@ npm -g gulp
gulp watch gulp watch
``` ```
Then you can run Then you can run the command with `DEBUG` flags for just this library
```
DEBUG=vivliostyle-electron:* vivliostyle-electron ./path/to/index.html --output
```
or for all conversion processes
``` ```
DEBUG=* vivliostyle-electron ./path/to/index.html --output DEBUG=* vivliostyle-electron ./path/to/index.html --output
``` ```
......
...@@ -48,7 +48,8 @@ var tmpPath; ...@@ -48,7 +48,8 @@ var tmpPath;
var hyphenator; var hyphenator;
var hyphenateOptions; var hyphenateOptions;
if (path.extname(relativePath) != ('.html' || '.xhtml')) {
if (['.html', '.xhtml'].indexOf(path.extname(relativePath)) === -1) {
console.error("Must pass a html or xhtml file as input"); console.error("Must pass a html or xhtml file as input");
return process.exit(1); return process.exit(1);
} }
...@@ -60,7 +61,7 @@ try { ...@@ -60,7 +61,7 @@ try {
return process.exit(1); return process.exit(1);
} }
if (program.output) { if (typeof(program.output) === "string") {
output = path.resolve(dir, program.output); output = path.resolve(dir, program.output);
} else if (typeof(program.output) != "undefined") { } else if (typeof(program.output) != "undefined") {
output = './' + replaceExt(path.basename(input), '.pdf'); output = './' + replaceExt(path.basename(input), '.pdf');
...@@ -97,7 +98,7 @@ renderer.process(tmpPath || input, output) ...@@ -97,7 +98,7 @@ renderer.process(tmpPath || input, output)
if (output) { if (output) {
msg += " to " + ouput; msg += " to " + ouput;
} }
console.log(msg); console.log(msg);
}, function (err) { }, function (err) {
......
...@@ -60,6 +60,8 @@ Renderer.prototype.process = function (inputPath, outputPath, options) { ...@@ -60,6 +60,8 @@ Renderer.prototype.process = function (inputPath, outputPath, options) {
var settings = options ? this.determineSettings(options) : this.settings; var settings = options ? this.determineSettings(options) : this.settings;
log("Processing from input %s", inputPath);
var result = this.convert(inputPath, settings); var result = this.convert(inputPath, settings);
result.then(function (result) { result.then(function (result) {
...@@ -139,6 +141,8 @@ Renderer.prototype.convert = function (inputPath, settings) { ...@@ -139,6 +141,8 @@ Renderer.prototype.convert = function (inputPath, settings) {
var url = this.encodeUrl(inputPath, settings); var url = this.encodeUrl(inputPath, settings);
var fullUrl = url + this.settingsToUriComponent(settings); var fullUrl = url + this.settingsToUriComponent(settings);
log("Converting from %s", fullUrl);
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
this.converter({ this.converter({
url: fullUrl, url: fullUrl,
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
"hypher": "^0.2.4", "hypher": "^0.2.4",
"replace-ext": "^1.0.0", "replace-ext": "^1.0.0",
"temp": "^0.8.3", "temp": "^0.8.3",
"vivliostyle": "next" "vivliostyle": "2016.7.0"
}, },
"devDependencies": { "devDependencies": {
"babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-add-module-exports": "^0.2.1",
......
...@@ -39,6 +39,8 @@ Renderer.prototype.determineSettings = function (_options) { ...@@ -39,6 +39,8 @@ Renderer.prototype.determineSettings = function (_options) {
Renderer.prototype.process = function (inputPath, outputPath, options) { Renderer.prototype.process = function (inputPath, outputPath, options) {
var settings = options ? this.determineSettings(options) : this.settings; var settings = options ? this.determineSettings(options) : this.settings;
log("Processing from input %s", inputPath);
var result = this.convert(inputPath, settings) var result = this.convert(inputPath, settings)
result.then((result) => { result.then((result) => {
...@@ -121,6 +123,8 @@ Renderer.prototype.convert = function(inputPath, settings) { ...@@ -121,6 +123,8 @@ Renderer.prototype.convert = function(inputPath, settings) {
var url = this.encodeUrl(inputPath, settings); var url = this.encodeUrl(inputPath, settings);
var fullUrl = url + this.settingsToUriComponent(settings); var fullUrl = url + this.settingsToUriComponent(settings);
log("Converting from %s", fullUrl);
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
this.converter({ this.converter({
url: fullUrl, url: fullUrl,
......
...@@ -8,7 +8,7 @@ describe('CLI', function() { ...@@ -8,7 +8,7 @@ describe('CLI', function() {
this.timeout(5000); this.timeout(5000);
it('should not error', function(done) { it('should not error when a html file is passed', function(done) {
var cli = spawn(path, ["./test/samples/wood/index.html"]) var cli = spawn(path, ["./test/samples/wood/index.html"])
...@@ -24,6 +24,17 @@ describe('CLI', function() { ...@@ -24,6 +24,17 @@ describe('CLI', function() {
}); });
it('should not error when a xhtml file is passed', function(done) {
var cli = spawn(path, ["./test/samples/TheMalayArchipelago/main.xhtml"])
cli.on('close', function(code){
assert.equal(code, 0);
done();
});
});
it('should error when no input is passed', function(done) { it('should error when no input is passed', function(done) {
var cli = spawn(path, [""]); var cli = spawn(path, [""]);
...@@ -58,7 +69,7 @@ describe('CLI', function() { ...@@ -58,7 +69,7 @@ describe('CLI', function() {
}); });
it('should report correct number of pages', function(done) { it('should report correct number of pages', function(done) {
var cli = spawn(path, ["./test/samples/wood/index.html"], { _showOutput: true }) var cli = spawn(path, ["./test/samples/wood/index.html"])
cli.stdout.on('data', function(data) { cli.stdout.on('data', function(data) {
var dataStr = data.toString(); var dataStr = data.toString();
...@@ -67,6 +78,16 @@ describe('CLI', function() { ...@@ -67,6 +78,16 @@ describe('CLI', function() {
}); });
}); });
it('should output to a given path', function(done) {
var cli = spawn(path, ["./test/samples/wood/index.html", "--output", "./test/output/wood.pdf"])
cli.on('close', function(code){
assert.equal(code, 0);
done();
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment