Skip to content

Commit

Permalink
Standardised code formatting in all files
Browse files Browse the repository at this point in the history
  • Loading branch information
MKHenson committed Oct 17, 2016
1 parent 4b81770 commit e1b32ad
Show file tree
Hide file tree
Showing 47 changed files with 2,439 additions and 2,814 deletions.
76 changes: 38 additions & 38 deletions git-logs.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
var util = require('util')
var fs = require('fs')
var exec = require('child_process').exec;
var util = require( 'util' )
var fs = require( 'fs' )
var exec = require( 'child_process' ).exec;
var child;

var prevTag = "v0.4.2";
var nextTag = "v0.4.3";


// Executes the git log command
child = exec('git log '+ prevTag +'...'+ nextTag +' --pretty=format:"{ \\"author\\" : \\"%an\\", \\"commit\\" : \\"%h\\", \\"date\\" : \\"%ar\\", \\"title\\" : \\"%s\\" },"', function (error, stdout, stderr) {

var jsonStr = "{ \"data\" : [ " + stdout.toString();
jsonStr = jsonStr.substr(0, jsonStr.length - 1) + " ] } ";

try {
var json = JSON.parse(jsonStr);
json = json.data;

console.log("Parsed JSON" )

var changes = "";
for ( var i = 0, l = json.length; i < l; i++ )
changes += `* ${json[i].title} - see ${json[i].commit} \n`;

try {
fs.writeFile( 'changes.md', changes, function(err){
if (err)
throw err;
console.log('It\'s saved!');
});
}
catch(err){
console.log('Could not write file: ' + err);
}
}
catch(err){
console.log('Could not parse JSON: ' + err);
console.log('JSON STRING: ' + jsonStr);
}


if (error !== null) {
console.log('exec error: ' + error);
}
child = exec( 'git log ' + prevTag + '...' + nextTag + ' --pretty=format:"{ \\"author\\" : \\"%an\\", \\"commit\\" : \\"%h\\", \\"date\\" : \\"%ar\\", \\"title\\" : \\"%s\\" },"', function( error, stdout, stderr ) {

var jsonStr = "{ \"data\" : [ " + stdout.toString();
jsonStr = jsonStr.substr( 0, jsonStr.length - 1 ) + " ] } ";

try {
var json = JSON.parse( jsonStr );
json = json.data;

console.log( "Parsed JSON" )

var changes = "";
for ( var i = 0, l = json.length; i < l; i++ )
changes += `* ${json[ i ].title} - see ${json[ i ].commit} \n`;

try {
fs.writeFile( 'changes.md', changes, function( err ) {
if ( err )
throw err;
console.log( 'It\'s saved!' );
});
}
catch ( err ) {
console.log( 'Could not write file: ' + err );
}
}
catch ( err ) {
console.log( 'Could not parse JSON: ' + err );
console.log( 'JSON STRING: ' + jsonStr );
}


if ( error !== null ) {
console.log( 'exec error: ' + error );
}
});
56 changes: 23 additions & 33 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,54 @@ var args = yargs.argv;
var numCPUs = os.cpus().length;

// Check for the threads argument
if (args.numThreads)
{
if (args.numThreads == "max")
{
console.log(`Setting the number of clusters to ${numCPUs}`);
if ( args.numThreads ) {
if ( args.numThreads == "max" ) {
console.log( `Setting the number of clusters to ${numCPUs}` );
}
else if (isNaN(parseInt(args.numThreads)))
{
console.log("attribute numThreads must be a number");
else if ( isNaN( parseInt( args.numThreads ) ) ) {
console.log( "attribute numThreads must be a number" );
process.exit();
}
else if (args.numThreads > numCPUs)
{
console.log(`You only have ${numCPUs} threads available - attribute numThreads will be set to ${numCPUs}`);
else if ( args.numThreads > numCPUs ) {
console.log( `You only have ${numCPUs} threads available - attribute numThreads will be set to ${numCPUs}` );
}
else if (args.numThreads)
{
console.log(`Setting the number of clusters to ${args.numThreads}`);
else if ( args.numThreads ) {
console.log( `Setting the number of clusters to ${args.numThreads}` );
numCPUs = args.numThreads;
}
}

// Run as a single cluster
if (numCPUs == 1)
{
console.log(`Running as single cluster`);
require("./src/startup.js");
if ( numCPUs == 1 ) {
console.log( `Running as single cluster` );
require( "./src/startup.js" );
}
else if (cluster.isMaster)
{
else if ( cluster.isMaster ) {
// Fork workers.
for (var i = 0; i < numCPUs; i++)
for ( var i = 0; i < numCPUs; i++ )
cluster.fork();

// List each of the process ID's
Object.keys(cluster.workers).forEach(function (id)
{
console.log("Starting cluster with ID : " + cluster.workers[id].process.pid);
Object.keys( cluster.workers ).forEach( function( id ) {
console.log( "Starting cluster with ID : " + cluster.workers[ id ].process.pid );
});

// When a cluster dies - lets try start it up again
cluster.on('exit', function (deadWorker, code, signal)
{
cluster.on( 'exit', function( deadWorker, code, signal ) {
var worker = cluster.fork();

// Note the process IDs
var newPID = worker.process.pid;
var oldPID = deadWorker.process.pid;

console.log(`Cluster ${worker.process.pid} died`);
console.log(`Attempting to restart failed cluster`);
console.log( `Cluster ${worker.process.pid} died` );
console.log( `Attempting to restart failed cluster` );

// Log the event
console.log(`worker ${oldPID} died`);
console.log(`worker ${newPID} born`);
console.log( `worker ${oldPID} died` );
console.log( `worker ${newPID} born` );
});
}
else
{
require("./src/startup.js");
else {
require( "./src/startup.js" );
}
2 changes: 1 addition & 1 deletion modepress-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as _UsersService from "./src/users-service";
import * as _SchemaFactory from "./src/models/schema-items/schema-item-factory";
import * as _EventManager from "./src/event-manager";
import * as _PermissionController from "./src/permission-controllers";
import {Utils} from "./src/utils";
import { Utils } from "./src/utils";

export var Controller = _Controller.Controller;
export var Model = _Models.Model;
Expand Down
Loading

0 comments on commit e1b32ad

Please sign in to comment.