Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
semi-spacing: 2
strict: 2
no-var: 2
prefer-template: 2
template-curly-spacing: 2
no-template-curly-in-string: 2

extends: eslint:recommended
20 changes: 10 additions & 10 deletions bin/citgm-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ const options = {
};

if (options.includeTags.length){
log.info('includeTags', 'Only running tests matching these tags: '
+ app.includeTags);
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);
log.info('excludeTags', `Not running tests matching these tags: ${
app.excludeTags}`);
}

const lookup = getLookup(options);
Expand All @@ -94,7 +94,7 @@ if (!lookup) {
const cpus = os.cpus().length;
if (app.autoParallel || (app.parallel && app.parallel > cpus)) {
app.parallel = cpus;
log.info('cores', 'running tests using ' + app.parallel + ' cores');
log.info('cores', `running tests using ${app.parallel} cores`);
}
if (app.parallel && ((app.parallel + 1) > process.getMaxListeners())) {
process.setMaxListeners(app.parallel + 1);
Expand Down Expand Up @@ -153,13 +153,13 @@ function runCitgm (mod, name, next) {
log[type](key, message);
}).on('end', function(result) {
result.duration = new Date() - start;
log.info('duration', 'test duration: ' + result.duration + 'ms');
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');
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.');
log.info(`${result.name} done`, `done - the test suite for ${result.name
Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

@SimenB SimenB Oct 23, 2018

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:

Details
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:

image

} version ${result.version} passed.`);
}
modules.push(result);
if (!bailed) {
Expand Down
2 changes: 1 addition & 1 deletion bin/citgm.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function launch(mod, options) {
module.duration = new Date() - start;
reporter.logger(log, module);

log.info('duration', 'test duration: ' + module.duration + 'ms');
log.info('duration', `test duration: ${module.duration}ms`);
if (app.markdown) {
reporter.markdown(log.bypass, module);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/citgm.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function findNode(context, next) {
next(err);
return;
}
context.emit('data', 'verbose', context.module.name + ' using-node',
context.emit('data', 'verbose', `${context.module.name} using-node`,
resolved);
next(null, context);
});
Expand All @@ -59,13 +59,13 @@ function init(context, next) {
// Single module that citgm is testing.
if (!windows) {
if (context.options.uid)
context.emit('data', 'verbose', context.module.name + ' using-uid',
context.emit('data', 'verbose', `${context.module.name} using-uid`,
context.options.uid);
if (context.options.gid)
context.emit('data', 'verbose', context.module.name + ' using-gid',
context.emit('data', 'verbose', `${context.module.name} using-gid`,
context.options.gid);
}
context.emit('data', 'silly', context.module.name + ' init-detail',
context.emit('data', 'silly', `${context.module.name} init-detail`,
context.module);
next(null, context); // Inject the context
}
Expand Down Expand Up @@ -137,10 +137,10 @@ Tester.prototype.run = function() {
payload.error = 'this module should have failed';
}
if (this.testOutput !== '') {
payload.testOutput += this.testOutput.toString() + '\n';
payload.testOutput += `${this.testOutput.toString()}\n`;
}
if (this.testError !== '') {
payload.testOutput += this.testError.toString() + '\n';
payload.testOutput += `${this.testError.toString()}\n`;
}
tempDirectory.remove(this, () => {
this.emit('end', payload);
Expand Down
4 changes: 2 additions & 2 deletions lib/grab-module-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function grabModuleData(context, next) {
});
proc.on('close', function(code) {
if (code > 0) {
context.emit('data', 'silly', context.module.name + ' npm-view',
context.emit('data', 'silly', `${context.module.name} npm-view`,
'No npm package information available');
if (context.module.type === 'git' &&
context.module.hosted.type === 'github') {
Expand All @@ -35,7 +35,7 @@ function grabModuleData(context, next) {
next(null, context);
return;
}
context.emit('data', 'silly', context.module.name + ' npm-view',
context.emit('data', 'silly', `${context.module.name} npm-view`,
'Data retrieved');
try {
context.meta = JSON.parse(data);
Expand Down
12 changes: 6 additions & 6 deletions lib/grab-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ const spawn = require('./spawn');

function grabProject(context, next) {
if (context.meta)
context.emit('data', 'silly', context.module.name + ' package-meta',
context.emit('data', 'silly', `${context.module.name} package-meta`,
context.meta);
let packageName = context.module.raw;
if (context.module.type === 'directory') {
context.module.raw = context.module.name = path.basename(packageName);
packageName = path.resolve(process.cwd(), packageName);
}
let bailed = false;
context.emit('data', 'info', context.module.name + ' npm:',
'Downloading project: ' + packageName);
context.emit('data', 'info', `${context.module.name} npm:`,
`Downloading project: ${packageName}`);
let options = createOptions(context.path, context);
options.stdio = ['ignore', 'pipe', 'ignore'];
const proc = spawn('npm', ['pack', packageName], options);
Expand All @@ -29,7 +29,7 @@ function grabProject(context, next) {
function cleanup() {
clearTimeout(timeout);
bailed = true;
context.emit('data', 'error', context.module.name + ' npm:',
context.emit('data', 'error', `${context.module.name} npm:`,
'Download Timed Out');
proc.kill();
return next(Error('Download Timed Out'));
Expand Down Expand Up @@ -59,8 +59,8 @@ function grabProject(context, next) {
if (filename === '') {
return next(Error('No project downloaded'));
}
context.emit('data', 'info', context.module.name + ' npm:',
'Project downloaded ' + filename);
context.emit('data', 'info', `${context.module.name} npm:`,
`Project downloaded ${filename}`);
context.unpack = path.join(context.path, filename);
return next(null, context);
});
Expand Down
8 changes: 4 additions & 4 deletions lib/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ function resolve(context, next) {
meta['dist-tags'],
rep.master ? null : rep.prefix,
context.options.sha || rep.sha || gitHead);
context.emit('data', 'info', context.module.name +
' lookup-replace', url);
context.emit('data', 'info', `${context.module.name
} lookup-replace`, url);
context.module.raw = url;
}
if (rep.install) {
context.emit('data', 'verbose', context.module.name +
' lookup-install', rep.install);
context.emit('data', 'verbose', `${context.module.name
} lookup-install`, rep.install);
context.module.install = rep.install;
}
if (rep.tags) {
Expand Down
6 changes: 3 additions & 3 deletions lib/match-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const semver = require('semver');

// Mocked in tests
let version = process.version;
let semVersion = semver.major(process.version) + '.' +
semver.minor(process.version) + '.' +
semver.patch(process.version);
let semVersion = `${semver.major(process.version)}.${
semver.minor(process.version)}.${
semver.patch(process.version)}`;
let platform = process.platform;
let arch = process.arch;
let distro = '';
Expand Down
2 changes: 1 addition & 1 deletion lib/out.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = function(options) {
output(tag, message, logger.error);
},
bypass: function(messgage) {
process.stdout.write(messgage + '\n');
process.stdout.write(`${messgage}\n`);
}
};
};
28 changes: 14 additions & 14 deletions lib/package-manager/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ function install(packageManager, context, next) {
createOptions(
path.join(context.path, context.module.name), context);
let args = ['install'];
context.emit('data', 'info', context.module.name + ' ' + packageManager +
':',
packageManager + ' install started');
context.emit('data', 'info', `${context.module.name} ${packageManager
}:`,
`${packageManager} install started`);

context.emit('data', 'verbose', context.module.name + ' ' + packageManager +
':',
'Using temp directory: "' + options.env['npm_config_tmp'] + '"');
context.emit('data', 'verbose', `${context.module.name} ${packageManager
}:`,
`Using temp directory: "${options.env['npm_config_tmp']}"`);

if (context.module.install) {
args = args.concat(context.module.install);
Expand All @@ -29,7 +29,7 @@ function install(packageManager, context, next) {
: context.yarnPath;

const binDirectory = path.dirname(packageManagerBin);
options.env.PATH = binDirectory + ':' + process.env.PATH;
options.env.PATH = `${binDirectory}:${process.env.PATH}`;

const proc = spawn(packageManagerBin, args, options);
const finish = timeout(context, proc, next, 'Install');
Expand All @@ -40,8 +40,8 @@ function install(packageManager, context, next) {
chunk = stripAnsi(chunk.toString());
chunk = chunk.replace(/\r/g, '\n');
}
context.emit('data', 'warn', context.module.name +
' ' + packageManager + '-install:',
context.emit('data', 'warn', `${context.module.name
} ${packageManager}-install:`,
chunk.toString());
});

Expand All @@ -51,8 +51,8 @@ function install(packageManager, context, next) {
chunk = stripAnsi(chunk.toString());
chunk = chunk.replace(/\r/g, '\n');
}
context.emit('data', 'verbose', context.module.name +
' ' + packageManager + '-install:',
context.emit('data', 'verbose', `${context.module.name
} ${packageManager}-install:`,
chunk.toString());
});

Expand All @@ -64,9 +64,9 @@ function install(packageManager, context, next) {
if (code > 0) {
return finish(Error('Install Failed'));
}
context.emit('data', 'info', context.module.name + ' ' +
packageManager + ':',
packageManager + ' install successfully completed');
context.emit('data', 'info', `${context.module.name} ${
packageManager}:`,
`${packageManager} install successfully completed`);
return finish(null, context);
});
}
Expand Down
22 changes: 11 additions & 11 deletions lib/package-manager/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ function authorName(author) {
if (typeof author === 'string') return author;
let parts = [];
if (author.name) parts.push(author.name);
if (author.email) parts.push('<' + author.email + '>');
if (author.url) parts.push('(' + author.url + ')');
if (author.email) parts.push(`<${author.email}>`);
if (author.url) parts.push(`(${author.url})`);
return parts.join(' ');
}

function test(packageManager, context, next) {
const wd = path.join(context.path, context.module.name);
context.emit('data', 'info', context.module.name + ' ' + packageManager + ':',
context.emit('data', 'info', `${context.module.name} ${packageManager}:`,
'test suite started');
readPackage(path.join(wd, 'package.json'), false, function(err, data) {
if (err) {
Expand All @@ -32,18 +32,18 @@ function test(packageManager, context, next) {
if (data.scripts === undefined ||
data.scripts.test === undefined) {
if (data.author) {
context.emit('data', 'warn', context.module.name + ' notice',
'Please contact the module developer to request adding ' +
packageManager + '' + ' test support: ' + authorName(data.author));
context.emit('data', 'warn', `${context.module.name} notice`,
`Please contact the module developer to request adding ${
packageManager}` + ` test support: ${authorName(data.author)}`);
}
next(new Error('Module does not support ' + packageManager + '-test!'));
next(new Error(`Module does not support ${packageManager}-test!`));
return;
}

const options = createOptions(wd, context);
let nodeBin = 'node';
if (context.options.testPath) {
options.env.PATH = context.options.testPath + ':' + process.env.PATH;
options.env.PATH = `${context.options.testPath}:${process.env.PATH}`;
nodeBin = which(nodeBinName, {path: options.env.PATH
|| process.env.PATH});
}
Expand All @@ -53,7 +53,7 @@ function test(packageManager, context, next) {
: context.yarnPath;

const binDirectory = path.dirname(packageManagerBin);
options.env.PATH = binDirectory + ':' + process.env.PATH;
options.env.PATH = `${binDirectory}:${process.env.PATH}`;

/* Run `npm/yarn test`, or `/path/to/customTest.js` if the customTest option
was passed */
Expand All @@ -69,12 +69,12 @@ function test(packageManager, context, next) {
data = stripAnsi(data.toString());
data = data.replace(/\r/g, '\n');
}
context.emit('data', 'verbose', context.module.name + ' npm-test:',
context.emit('data', 'verbose', `${context.module.name} npm-test:`,
data.toString());
});
proc.stderr.on('data', function (data) {
context.testError.append(data);
context.emit('data', 'verbose', context.module.name + ' npm-test:',
context.emit('data', 'verbose', `${context.module.name} npm-test:`,
data.toString());
});
proc.on('error', function() {
Expand Down
6 changes: 3 additions & 3 deletions lib/reporter/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const util = require('./util');
function generateTest(xml, mod) {
const output =util.sanitizeOutput(mod.testOutput, '', true);
const item = xml.ele('testcase');
item.att('name', [mod.name, 'v' + mod.version].join('-'));
item.att('name', [mod.name, `v${mod.version}`].join('-'));
item.att('time', mod.duration / 1000);
item.ele('system-out').dat(output);
if (mod.skip || (mod.flaky && mod.error)) {
Expand Down Expand Up @@ -37,9 +37,9 @@ function junit(logger, modules, append) {
const payload = generateJunit(modules);
if (typeof logger === 'string') {
if (append){
fs.appendFileSync(logger, payload + '\n');
fs.appendFileSync(logger, `${payload}\n`);
} else {
fs.writeFileSync(logger, payload + '\n');
fs.writeFileSync(logger, `${payload}\n`);
}
} else {
logger(payload);
Expand Down
8 changes: 4 additions & 4 deletions lib/reporter/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const util = require('./util');

function printModulesMarkdown(logger, title, modules) {
if (modules.length > 0) {
logger('### ' + title + ' Modules');
logger(`### ${title} Modules`);
_.each(modules, function (mod) {
logger(' * ' + mod.name + ' v' + mod.version + ' duration:' +
mod.duration + 'ms');
logger(` * ${mod.name} v${mod.version} duration:${
mod.duration}ms`);
if (mod.error) {
logger(' - ' + mod.error.message);
logger(` - ${mod.error.message}`);
}
if (mod.error && mod.testOutput) {
logger(util.sanitizeOutput(mod.testOutput, ' - '));
Expand Down
Loading