-
-
Notifications
You must be signed in to change notification settings - Fork 156
chore: use template strings #611
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
Conversation
| } else { | ||
| log.info(result.name + ' done', 'done - the test suite for ' + result.name | ||
| + ' version ' + result.version + ' passed.'); | ||
| log.info(`${result.name} done`, `done - the test suite for ${result.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is pretty ugly... I can clean it up manually if you reject #612. If that is accepted, prettier deals with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does it look like when prettier is applied?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff in this file after applying prettier on top of it:
diff --git c/bin/citgm-all.js w/bin/citgm-all.js
index 0582670..f68433b 100755
--- c/bin/citgm-all.js
+++ w/bin/citgm-all.js
@@ -39,11 +39,13 @@ const yargs = commonArgs(require('yargs'))
type: 'array',
description: 'Define which tags from the lookup to skip'
})
- .example('citgm-all -t /path/to/output.tap',
- 'Write test results as tap to file.')
+ .example(
+ 'citgm-all -t /path/to/output.tap',
+ 'Write test results as tap to file.'
+ )
.example('citgm-all -l /path/to/lookup.json', 'Test a custom set of modules.')
.example('citgm-all --includeTags express', 'Only test express.')
- .example('citgm-all --excludeTags native', 'Don\'t test native modules.');
+ .example('citgm-all --excludeTags native', "Don't test native modules.");
const app = yargs.argv;
@@ -56,7 +58,7 @@ update(log);
if (!app.su) {
require('root-check')(); // Silently downgrade if running as root...
- // Unless --su is passed
+ // Unless --su is passed
} else {
log.warn('root', 'Running as root! Use caution!');
}
@@ -75,13 +77,17 @@ const options = {
excludeTags: app.excludeTags || []
};
-if (options.includeTags.length){
- log.info('includeTags', `Only running tests matching these tags: ${
- app.includeTags}`);
+if (options.includeTags.length) {
+ log.info(
+ 'includeTags',
+ `Only running tests matching these tags: ${app.includeTags}`
+ );
}
-if (options.excludeTags.length){
- log.info('excludeTags', `Not running tests matching these tags: ${
- app.excludeTags}`);
+if (options.excludeTags.length) {
+ log.info(
+ 'excludeTags',
+ `Not running tests matching these tags: ${app.excludeTags}`
+ );
}
const lookup = getLookup(options);
@@ -95,7 +101,7 @@ if (app.autoParallel || (app.parallel && app.parallel > cpus)) {
app.parallel = cpus;
log.info('cores', `running tests using ${app.parallel} cores`);
}
-if (app.parallel && ((app.parallel + 1) > process.getMaxListeners())) {
+if (app.parallel && app.parallel + 1 > process.getMaxListeners()) {
process.setMaxListeners(app.parallel + 1);
}
@@ -114,7 +120,7 @@ if (!citgm.windows) {
const modules = [];
-function runCitgm (mod, name, next) {
+function runCitgm(mod, name, next) {
if (isMatch(mod.skip)) {
modules.push({
name,
@@ -144,30 +150,43 @@ function runCitgm (mod, name, next) {
process.on('SIGHUP', cleanup);
process.on('SIGBREAK', cleanup);
- runner.on('start', function(name) {
- log.info('starting', name);
- }).on('fail', function(err) {
- log.error('failure', err.message);
- }).on('data', function(type, key, message) {
- log[type](key, message);
- }).on('end', function(result) {
- result.duration = new Date() - start;
- log.info('duration', `test duration: ${result.duration}ms`);
- if (result.error) {
- log.error(`${result.name} done`, `done - the test suite for ${
- result.name} version ${result.version} failed`);
- } else {
- log.info(`${result.name} done`, `done - the test suite for ${result.name
- } version ${result.version} passed.`);
- }
- modules.push(result);
- if (!bailed) {
- process.removeListener('SIGINT', cleanup);
- process.removeListener('SIGHUP', cleanup);
- process.removeListener('SIGBREAK', cleanup);
- }
- return next(bailed);
- }).run();
+ runner
+ .on('start', function(name) {
+ log.info('starting', name);
+ })
+ .on('fail', function(err) {
+ log.error('failure', err.message);
+ })
+ .on('data', function(type, key, message) {
+ log[type](key, message);
+ })
+ .on('end', function(result) {
+ result.duration = new Date() - start;
+ log.info('duration', `test duration: ${result.duration}ms`);
+ if (result.error) {
+ log.error(
+ `${result.name} done`,
+ `done - the test suite for ${result.name} version ${
+ result.version
+ } failed`
+ );
+ } else {
+ log.info(
+ `${result.name} done`,
+ `done - the test suite for ${result.name} version ${
+ result.version
+ } passed.`
+ );
+ }
+ modules.push(result);
+ if (!bailed) {
+ process.removeListener('SIGINT', cleanup);
+ process.removeListener('SIGHUP', cleanup);
+ process.removeListener('SIGBREAK', cleanup);
+ }
+ return next(bailed);
+ })
+ .run();
}
function runTask(task, next) {
@@ -187,7 +206,7 @@ function launch() {
const q = async.queue(runTask, app.parallel || 1);
q.push(collection);
- function done () {
+ function done() {
q.drain = null;
reporter.logger(log, modules);
@@ -200,12 +219,12 @@ function launch() {
// If not use `log.bypass` which is currently process.stdout.write
// TODO check that we can write to that path, perhaps require a flag to
// Overwrite
- const tap = (typeof app.tap === 'string') ? app.tap : log.bypass;
+ const tap = typeof app.tap === 'string' ? app.tap : log.bypass;
reporter.tap(tap, modules, app.append);
}
if (app.junit) {
- const junit = (typeof app.junit === 'string') ? app.junit : log.bypass;
+ const junit = typeof app.junit === 'string' ? app.junit : log.bypass;
reporter.junit(junit, modules, app.append);
}
A bit hard to read the part I commented about due to the whitespace changes, so here's a screenshot with word highlighting:
|
Might consider using arrow functions as well. eslint autofixes that as well, want me to send a PR? |
|
I'm personally all for it (this PR, prettier, arrow functions). The more we can automate code style, the better. @nodejs/citgm any objection to doing that? |
|
Cool, I'll open up a 3rd PR with arrows (can combine them if you want) |
|
Going to let #560 land before landing this to avoid conflcits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR can be updated
|
I rebased this, the arrow function and the prettier PRs, so they should all be ready to land 🙂 |
|
landed in ec66f36 |

Requested by @MylesBorins in #560, I thought it'd be easier to land separately to reduce the diff.
This just added the eslint rule and runs autofix
Checklist