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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
sudo: required
dist: trusty
addons:
apt:
packages:
- google-chrome-beta
chrome: stable
code_climate:
repo_token: e87e6bf1c253e0555437ebd23235fdfe2749b889358e7c6d100e4ea5b4f2e091
language: node_js
Expand Down
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
5 changes: 3 additions & 2 deletions test/cli_test-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path')
const test = require('tape')
const rimraf = require('rimraf')

const localSearchPath = './node_modules/.bin' + path.delimiter + process.env.PATH
const testDir = 'test/fixtures/samples/'.replace('/', path.sep)
const phantomjs = 'node_modules/.bin/phantomjs '.replace('/', path.sep)
const loadHtmlSaveScreenshotPngScripts = testDir + path.sep + 'load_html_save_screenshot_png.phantomjs'
Expand All @@ -28,7 +29,7 @@ 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: Object.assign({}, process.env, { PATH: localSearchPath }) },
function (error, stdout, stderr) {
console.log('error:', error, '\nstdout:\n', stdout, '\nstderr:\n', stderr)
verify(error, stdout, stderr)
Expand Down Expand Up @@ -72,7 +73,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