Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CLI output #536

Merged
merged 9 commits into from
May 31, 2017
Merged
10 changes: 5 additions & 5 deletions lib/phantomscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ page.content = [

page.injectJs('../dist/mermaid.js')
page.onConsoleMessage = function (msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")')
log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")')
}

console.log('Num files to execute : ' + files.length)
log('Num files to execute : ' + files.length)

files.forEach(function (file) {
var contents = fs.read(file)
Expand All @@ -75,7 +75,7 @@ files.forEach(function (file) {
var oDOM
var svgContent

console.log('ready to execute png: ' + filename + '.png ')
log('ready to execute: ' + file)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this change makes execution completely silent without --verbose. If that's undesirable, we could use console.log for "ready to execute" and "saved" messages.


// this JS is executed in this statement is sandboxed, even though it doesn't
// look like it. we need to serialize then unserialize the svgContent that's
Expand All @@ -100,7 +100,7 @@ files.forEach(function (file) {
}

page.render(outputPath + '.png')
console.log('saved png: ' + filename + '.png')
log('saved png: ' + outputPath + '.png')
}

if (options.svg) {
Expand All @@ -109,7 +109,7 @@ files.forEach(function (file) {
, serialize.serializeToString(oDOM) + '\n'
, 'w'
)
log('saved svg: ' + filename + '.svg')
log('saved svg: ' + outputPath + '.svg')
}
})

Expand Down
9 changes: 7 additions & 2 deletions test/cli_test-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ function execPhantomjsToLoadHtmlSaveScreenshotPng (html, verify) {
function execCmd (cmd, verify) {
console.log('cmd: ', cmd)
exec(cmd,
{ env: { PATH: './node_modules/.bin' + path.delimiter + process.env.PATH } },
{ env: {
PATH: './node_modules/.bin' + path.delimiter + process.env.PATH,

// https://github.com/ariya/phantomjs/issues/14376
QT_QPA_PLATFORM: 'offscreen'
} },
function (error, stdout, stderr) {
console.log('error:', error, '\nstdout:\n', stdout, '\nstderr:\n', stderr)
verify(error, stdout, stderr)
Expand Down Expand Up @@ -72,7 +77,7 @@ test.skip('sequence syntax error', function (t) {
});

['', 'fo', 'tspan', 'old'].forEach(function (textPlacement) {
test('sequence svg text placelment: ' + textPlacement, function (t) {
test('sequence svg text placement: ' + textPlacement, function (t) {
t.plan(2)
const args = ['--svg',
'--outputDir=' + testDir,
Expand Down