diff --git a/test/clone.js b/test/clone.js index 38317127f..906120ede 100644 --- a/test/clone.js +++ b/test/clone.js @@ -26,7 +26,8 @@ var argv = minimist(process.argv.slice(2), { 'disabled', 'offline', 'quick', - 'quiet' + 'quiet', + 'fix' ] }) @@ -62,24 +63,19 @@ test('test github repos that use `standard`', function (t) { var folder = path.join(TMP, name) return function (cb) { fs.access(path.join(TMP, name), fs.R_OK | fs.W_OK, function (err) { - if (argv.offline) { - if (err) { - t.pass('SKIPPING (offline): ' + name + ' (' + pkg.repo + ')') - return cb(null) - } + if (argv.offline && err) { + t.pass('SKIPPING (offline): ' + name + ' (' + pkg.repo + ')') + cb(null) + } else if (argv.offline) { runStandard(cb) } else { + var downloadPackage = err ? gitClone : gitPull downloadPackage(function (err) { if (err) return cb(err) runStandard(cb) }) } - function downloadPackage (cb) { - if (err) gitClone(cb) - else gitPull(cb) - } - function gitClone (cb) { var args = [ 'clone', '--depth', 1, url, path.join(TMP, name) ] spawn(GIT, args, { stdio: 'ignore' }, function (err) { @@ -101,14 +97,12 @@ test('test github repos that use `standard`', function (t) { if (pkg.args) args.push.apply(args, pkg.args) spawn(STANDARD, args, { cwd: folder }, function (err) { var str = name + ' (' + pkg.repo + ')' - if (err) { - if (err.message.indexOf('(indent)') || err.message.indexOf('(no-multi-spaces)') || err.message.indexOf('(space-unary-ops)')) { - t.comment('Attempting to fix eslint breaking changes for ' + str) - runStandardFix(cb) - } else { - t.fail(str) - cb(null) - } + if (err && argv.fix) { + t.comment('Attempting --fix on ' + str) + runStandardFix(cb) + } else if (err) { + t.fail(str) + cb(null) } else { t.pass(str) cb(null) @@ -120,7 +114,7 @@ test('test github repos that use `standard`', function (t) { var args = [ '--fix', '--verbose' ] if (pkg.args) args.push.apply(args, pkg.args) spawn(STANDARD, args, { cwd: folder }, function (err) { - var str = name + ' (' + pkg.repo + ') **with --fix' + var str = name + ' (' + pkg.repo + ') ** with --fix' if (err) { t.fail(str) } else { t.pass(str) } runGitReset(cb) }) @@ -130,6 +124,7 @@ test('test github repos that use `standard`', function (t) { var args = [ 'reset', '--hard' ] spawn(GIT, args, { cwd: folder }, function (err) { if (err) err.message += ' (git reset) (' + name + ')' + // Fatal error if can't git reset cb(err) }) }