Skip to content

Commit

Permalink
Add test mode to QuickServer, see #141
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisklus committed May 23, 2022
1 parent e0345d5 commit bd8ea0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion js/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ module.exports = grunt => {

const port = grunt.option( 'port' ) ? Number.parseInt( grunt.option( 'port' ), 10 ) : 45367;

const server = new QuickServer();
const testing = grunt.option( 'testing' );
const server = new QuickServer( {
isTestMode: testing
} );
server.startServer( port );
server.startMainLoop();
}
Expand Down
15 changes: 12 additions & 3 deletions js/server/QuickServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,23 @@ const jsonHeaders = {
let lastBroken = false;

class QuickServer {
constructor( rootDir = path.normalize( `${__dirname}/../../../` ) ) {
constructor( options ) {

options = {
rootDir: path.normalize( `${__dirname}/../../../` ),
isTestMode: false,
...options
};

// @public {*}
this.reportState = {};

// @public {string} - root of your GitHub working copy, relative to the name of the directory that the
// currently-executing script resides in
this.rootDir = rootDir;
this.rootDir = options.rootDir;

// @public {boolean} - whether we are in testing mode. if true, tests are continuously forced to run
this.isTestMode = options.isTestMode;
}

/**
Expand Down Expand Up @@ -75,7 +84,7 @@ class QuickServer {
} ) );

if ( staleRepos.length || forceTests ) {
forceTests = false;
forceTests = this.isTestMode;

winston.info( `QuickServer: stale repos: ${staleRepos}` );

Expand Down

0 comments on commit bd8ea0d

Please sign in to comment.