Skip to content

Commit

Permalink
CLI: Move non-bin files from bin/ to src/cli/
Browse files Browse the repository at this point in the history
Follows-up #1271.
  • Loading branch information
Krinkle committed Dec 27, 2018
1 parent b54e732 commit 27a1d65
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions bin/qunit
Expand Up @@ -3,8 +3,8 @@
"use strict";

const program = require( "commander" );
const run = require( "./run" );
const FindReporter = require( "./find-reporter" );
const run = require( "../src/cli/run" );
const FindReporter = require( "../src/cli/find-reporter" );
const pkg = require( "../package.json" );

const findReporter = FindReporter.findReporter;
Expand Down
5 changes: 5 additions & 0 deletions src/cli/.eslintrc.json
@@ -0,0 +1,5 @@
{
"env": {
"node": true
}
}
2 changes: 1 addition & 1 deletion bin/find-reporter.js → src/cli/find-reporter.js
Expand Up @@ -4,7 +4,7 @@ const JSReporters = require( "js-reporters" );
const path = require( "path" );
const findup = require( "findup-sync" );
const utils = require( "./utils" );
const pkg = require( "../package.json" );
const pkg = require( "../../package.json" );

function findReporter( reporterName ) {
if ( !reporterName ) {
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions bin/require-qunit.js → src/cli/require-qunit.js
Expand Up @@ -13,14 +13,14 @@ module.exports = function requireQUnit() {
try {

// Second, we use the globally installed QUnit
delete require.cache[ resolve.sync( "../qunit/qunit" ) ];
return require( "../qunit/qunit" );
delete require.cache[ resolve.sync( "../../qunit/qunit" ) ];
return require( "../../qunit/qunit" );
} catch ( e ) {
if ( e.code === "MODULE_NOT_FOUND" ) {

// Finally, we use the local development version of QUnit
delete require.cache[ resolve.sync( "../dist/qunit" ) ];
return require( "../dist/qunit" );
delete require.cache[ resolve.sync( "../../dist/qunit" ) ];
return require( "../../dist/qunit" );
}

throw e;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/cli/custom-reporter.js
Expand Up @@ -2,7 +2,7 @@ const co = require( "co" );
const JSReporters = require( "js-reporters" );
const NPMReporter = require( "npm-reporter" );

const findReporter = require( "../../bin/find-reporter" ).findReporter;
const findReporter = require( "../../src/cli/find-reporter" ).findReporter;

const expectedOutput = require( "./fixtures/expected/tap-outputs" );
const execute = require( "./helpers/execute" );
Expand Down
18 changes: 9 additions & 9 deletions test/cli/require-qunit-test.js
Expand Up @@ -10,7 +10,7 @@ QUnit.module( "requireQUnit", function() {
const localQUnit = {
"@noCallThru": true
};
const requireQUnit = proxyquire( "../../bin/require-qunit", {
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": localQUnit
} );
Expand All @@ -22,10 +22,10 @@ QUnit.module( "requireQUnit", function() {
const globalQUnit = {
"@noCallThru": true
};
const requireQUnit = proxyquire( "../../bin/require-qunit", {
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": null,
"../qunit/qunit": globalQUnit
"../../qunit/qunit": globalQUnit
} );

assert.strictEqual( requireQUnit(), globalQUnit );
Expand All @@ -35,22 +35,22 @@ QUnit.module( "requireQUnit", function() {
const devQUnit = {
"@noCallThru": true
};
const requireQUnit = proxyquire( "../../bin/require-qunit", {
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": null,
"../qunit/qunit": null,
"../dist/qunit": devQUnit
"../../qunit/qunit": null,
"../../dist/qunit": devQUnit
} );

assert.strictEqual( requireQUnit(), devQUnit );
} );

QUnit.test( "throws error if none of the modules are found", function( assert ) {
const requireQUnit = proxyquire( "../../bin/require-qunit", {
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": null,
"../qunit/qunit": null,
"../dist/qunit": null
"../../qunit/qunit": null,
"../../dist/qunit": null
} );

assert.throws( requireQUnit, /Cannot find module/ );
Expand Down

0 comments on commit 27a1d65

Please sign in to comment.