diff --git a/README.md b/README.md index a86f11f..5a4446e 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ clinic upload --help ``` -h | --help Display Help -v | --version Display Version +--debug Do not minify generated files ``` ## Programmable Interfaces diff --git a/bin.js b/bin.js index 2796caa..f1b8958 100755 --- a/bin.js +++ b/bin.js @@ -88,7 +88,8 @@ const result = commist() 'help', 'version', 'collect-only', - 'open' + 'open', + 'debug' ], string: [ 'visualize-only', @@ -97,7 +98,8 @@ const result = commist() ], default: { 'sample-interval': '10', - 'open': true + 'open': true, + 'debug': false }, '--': true }) @@ -124,13 +126,15 @@ const result = commist() 'help', 'version', 'collect-only', - 'open' + 'open', + 'debug' ], string: [ 'visualize-only' ], default: { - 'open': true + open: true, + debug: false }, '--': true }) @@ -157,13 +161,15 @@ const result = commist() 'help', 'version', 'collect-only', - 'open' + 'open', + 'debug' ], string: [ 'visualize-only' ], default: { - 'open': true + open: true, + debug: false }, '--': true }) @@ -208,9 +214,18 @@ if (result !== null) { function runTool (args, Tool, version) { const onPort = args['on-port'] + if (!onPort && !args['visualize-only']) { + if (args['collect-only']) { + console.log('To stop data collection press: Ctrl + C') + } else { + console.log('To generate the report press: Ctrl + C') + } + } + const tool = new Tool({ sampleInterval: parseInt(args['sample-interval'], 10), - detectPort: !!onPort + detectPort: !!onPort, + debug: args.debug }) /* istanbul ignore next */ @@ -227,7 +242,7 @@ function runTool (args, Tool, version) { if (args['collect-only']) { tool.collect(args['--'], function (err, filename) { if (err) throw err - console.log(`output file is ${filename}`) + console.log(`Output file is ${filename}`) }) } else if (args['visualize-only']) { viz(args['visualize-only'], function (err) { diff --git a/test-local/cli-flame-collect-only.test.js b/test-local/cli-flame-collect-only.test.js index fdf13f3..d454ddb 100644 --- a/test-local/cli-flame-collect-only.test.js +++ b/test-local/cli-flame-collect-only.test.js @@ -28,7 +28,7 @@ test('clinic flame --collect-only - bad status code', function (t) { '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, '') + t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n') t.ok(stderr.includes('subprocess error, code: 1')) t.end() }) diff --git a/test-local/cli-flame-full.test.js b/test-local/cli-flame-full.test.js index 804d6e4..c1a74b1 100644 --- a/test-local/cli-flame-full.test.js +++ b/test-local/cli-flame-full.test.js @@ -39,7 +39,7 @@ test('clinic flame -- node - bad status code', function (t) { '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, '') + t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n') t.ok(stderr.includes('subprocess error, code: 1')) t.end() }) diff --git a/test-local/cli-flame-visualize-only.test.js b/test-local/cli-flame-visualize-only.test.js index ecf0e80..aee68c8 100644 --- a/test-local/cli-flame-visualize-only.test.js +++ b/test-local/cli-flame-visualize-only.test.js @@ -36,7 +36,7 @@ test('clinic flame --collect-only - missing data', function (t) { 'clinic', 'flame', '--visualize-only', 'missing.flamegraph' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, '') + t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n') t.ok(stderr.includes('Invalid data path provided')) t.end() }) diff --git a/test/cli-bubbleprof-collect-only.test.js b/test/cli-bubbleprof-collect-only.test.js index 5c691b9..3ecb500 100644 --- a/test/cli-bubbleprof-collect-only.test.js +++ b/test/cli-bubbleprof-collect-only.test.js @@ -7,11 +7,11 @@ const cli = require('./cli.js') test('clinic bubbleprof --collect-only - no issues', function (t) { cli({}, [ - 'clinic', 'bubbleprof', '--collect-only', + 'clinic', 'bubbleprof', '--collect-only', '--debug', '--', 'node', '-e', 'setTimeout(() => {}, 100)' ], function (err, stdout, stderr, tempdir) { t.ifError(err) - t.ok(/output file is (\d+).clinic-bubbleprof/.test(stdout)) + t.ok(/Output file is (\d+).clinic-bubbleprof/.test(stdout)) const dirname = stdout.match(/(\d+.clinic-bubbleprof)/)[1] fs.access(path.resolve(tempdir, dirname), function (err) { @@ -31,7 +31,7 @@ test('clinic bubbleprof --collect-only - bad status code', function (t) { '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, '') + t.strictEqual(stdout, 'To stop data collection press: Ctrl + C\n') t.ok(stderr.includes('process exited with exit code 1')) t.end() }) diff --git a/test/cli-bubbleprof-full.test.js b/test/cli-bubbleprof-full.test.js index a563ec1..8dc7767 100644 --- a/test/cli-bubbleprof-full.test.js +++ b/test/cli-bubbleprof-full.test.js @@ -15,8 +15,8 @@ test('clinic bubbleprof -- node - no issues', function (t) { t.ifError(err) const dirname = stdout.match(/(\d+.clinic-bubbleprof)/)[1] - t.strictEqual(stdout.split('\n')[0], 'Analysing data') - t.ok(stdout.split('\n')[1], `generated HTML file is ${dirname}.html`) + t.strictEqual(stdout.split('\n')[1], 'Analysing data') + t.strictEqual(stdout.split('\n')[2], `Generated HTML file is ${dirname}.html`) // check that files exists async.parallel({ @@ -40,7 +40,7 @@ test('clinic bubbleprof -- node - bad status code', function (t) { '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, '') + t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n') t.ok(stderr.includes('process exited with exit code 1')) t.end() }) @@ -62,7 +62,7 @@ test('clinic bubbleprof -- node - visualization error', function (t) { ` ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, 'Analysing data\n') + t.strictEqual(stdout, 'To generate the report press: Ctrl + C\nAnalysing data\n') t.ok(stderr.includes('ENOENT: no such file or directory')) t.end() }) diff --git a/test/cli-bubbleprof-visualize-only.test.js b/test/cli-bubbleprof-visualize-only.test.js index 7dd22dd..a3c1daf 100644 --- a/test/cli-bubbleprof-visualize-only.test.js +++ b/test/cli-bubbleprof-visualize-only.test.js @@ -12,7 +12,7 @@ test('clinic bubbleprof --collect-only - no issues', function (t) { '--', 'node', '-e', 'setTimeout(() => {}, 100)' ], function (err, stdout, stderr, tempdir) { t.ifError(err) - t.ok(/output file is (\d+).clinic-bubbleprof/.test(stdout)) + t.ok(/Output file is (\d+).clinic-bubbleprof/.test(stdout)) const dirname = stdout.match(/(\d+.clinic-bubbleprof)/)[1] const dirpath = path.resolve(tempdir, dirname) @@ -21,7 +21,12 @@ test('clinic bubbleprof --collect-only - no issues', function (t) { 'clinic', 'bubbleprof', '--visualize-only', dirpath ], function (err, stdout) { t.ifError(err) - t.strictEqual(stdout, `Generated HTML file is ${dirpath}.html\nYou can use this command to upload it:\nclinic upload ${dirpath}\n`) + t.strictEqual( + stdout, + `Generated HTML file is ${dirpath}.html +You can use this command to upload it: +clinic upload ${dirpath} +`) // check that HTML file exists fs.access(dirpath + '.html', function (err) { diff --git a/test/cli-doctor-collect-only.test.js b/test/cli-doctor-collect-only.test.js index 8651d98..b78f807 100644 --- a/test/cli-doctor-collect-only.test.js +++ b/test/cli-doctor-collect-only.test.js @@ -11,7 +11,7 @@ test('clinic doctor --collect-only - no issues', function (t) { '--', 'node', '-e', 'setTimeout(() => {}, 100)' ], function (err, stdout, stderr, tempdir) { t.ifError(err) - t.ok(/output file is (\d+).clinic-doctor/.test(stdout)) + t.ok(/Output file is (\d+).clinic-doctor/.test(stdout)) const dirname = stdout.match(/(\d+.clinic-doctor)/)[1] fs.access(path.resolve(tempdir, dirname), function (err) { @@ -31,7 +31,7 @@ test('clinic doctor --collect-only - bad status code', function (t) { '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, '') + t.strictEqual(stdout, 'To stop data collection press: Ctrl + C\n') t.ok(stderr.includes('process exited with exit code 1')) t.end() }) diff --git a/test/cli-doctor-full.test.js b/test/cli-doctor-full.test.js index e626e5a..b4fe62f 100644 --- a/test/cli-doctor-full.test.js +++ b/test/cli-doctor-full.test.js @@ -15,8 +15,8 @@ test('clinic doctor -- node - no issues', function (t) { t.ifError(err) const dirname = stdout.match(/(\d+.clinic-doctor)/)[1] - t.strictEqual(stdout.split('\n')[0], 'Analysing data') - t.ok(stdout.split('\n')[1], `generated HTML file is ${dirname}.html`) + t.strictEqual(stdout.split('\n')[1], 'Analysing data') + t.strictEqual(stdout.split('\n')[2], `Generated HTML file is ${dirname}.html`) // check that files exists async.parallel({ @@ -40,7 +40,7 @@ test('clinic doctor -- node - bad status code', function (t) { '--', 'node', '-e', 'process.exit(1)' ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, '') + t.strictEqual(stdout, 'To generate the report press: Ctrl + C\n') t.ok(stderr.includes('process exited with exit code 1')) t.end() }) @@ -62,7 +62,7 @@ test('clinic doctor -- node - visualization error', function (t) { ` ], function (err, stdout, stderr) { t.strictDeepEqual(err, new Error('process exited with exit code 1')) - t.strictEqual(stdout, 'Analysing data\n') + t.strictEqual(stdout, 'To generate the report press: Ctrl + C\nAnalysing data\n') t.ok(stderr.includes('ENOENT: no such file or directory')) t.end() }) diff --git a/test/cli-doctor-visualize-only.test.js b/test/cli-doctor-visualize-only.test.js index cce50c3..fde133b 100644 --- a/test/cli-doctor-visualize-only.test.js +++ b/test/cli-doctor-visualize-only.test.js @@ -12,7 +12,7 @@ test('clinic doctor --visualize-only - no issues', function (t) { '--', 'node', '-e', 'setTimeout(() => {}, 100)' ], function (err, stdout, stderr, tempdir) { t.ifError(err) - t.ok(/output file is (\d+).clinic-doctor/.test(stdout)) + t.ok(/Output file is (\d+).clinic-doctor/.test(stdout)) const dirname = stdout.match(/(\d+.clinic-doctor)/)[1] const dirpath = path.resolve(tempdir, dirname) @@ -21,7 +21,12 @@ test('clinic doctor --visualize-only - no issues', function (t) { 'clinic', 'doctor', '--visualize-only', dirpath ], function (err, stdout) { t.ifError(err) - t.strictEqual(stdout, `Generated HTML file is ${dirpath}.html\nYou can use this command to upload it:\nclinic upload ${dirpath}\n`) + t.strictEqual( + stdout, + `Generated HTML file is ${dirpath}.html +You can use this command to upload it: +clinic upload ${dirpath} +`) // check that HTML file exists fs.access(dirpath + '.html', function (err) {