From c5b8eec33a1d7f577a15006784b4c537c1af4213 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Sat, 9 Jan 2016 16:14:28 -0500 Subject: [PATCH] Move CLI-related assets to subfolder. --- src/{ => cli}/main.js | 19 ++++++++++--------- src/{ => cli}/out.js | 6 +++--- src/{ => cli}/use.txt | 0 src/core/error-handler.js | 2 +- src/index.js | 2 +- test/test-stdout.js | 6 +++--- 6 files changed, 18 insertions(+), 17 deletions(-) rename src/{ => cli}/main.js (93%) rename src/{ => cli}/out.js (97%) rename src/{ => cli}/use.txt (100%) diff --git a/src/main.js b/src/cli/main.js similarity index 93% rename from src/main.js rename to src/cli/main.js index 1d3405f..b19c10c 100644 --- a/src/main.js +++ b/src/cli/main.js @@ -10,18 +10,18 @@ Definition of the `main` function. - var HMR = require( './hackmyapi') - , PKG = require('../package.json') + var HMR = require( '../hackmyapi') + , PKG = require('../../package.json') , FS = require('fs') - , EXTEND = require('./utils/extend') + , EXTEND = require('../utils/extend') , chalk = require('chalk') , PATH = require('path') - , HACKMYSTATUS = require('./core/status-codes') - , HME = require('./core/event-codes') - , safeLoadJSON = require('./utils/safe-json-loader') + , HACKMYSTATUS = require('../core/status-codes') + , HME = require('../core/event-codes') + , safeLoadJSON = require('../utils/safe-json-loader') , _opts = { } , title = chalk.white.bold('\n*** HackMyResume v' + PKG.version + ' ***') - , StringUtils = require('./utils/string.js') + , StringUtils = require('../utils/string.js') , _ = require('underscore') , OUTPUT = require('./out') , Command = require('commander').Command; @@ -152,7 +152,8 @@ Definition of the `main` function. // Override the .helpInformation behavior Command.prototype.helpInformation = function() { - var manPage = FS.readFileSync( PATH.join(__dirname, 'use.txt'), 'utf8' ); + var manPage = FS.readFileSync( + PATH.join(__dirname, 'use.txt'), 'utf8' ); return chalk.green.bold(manPage); }; @@ -167,7 +168,7 @@ Definition of the `main` function. function execVerb( src, dst, opts, log ) { loadOptions.call( this, opts ); - require( './core/error-handler' ).init( _opts.debug ); + require( '../core/error-handler' ).init( _opts.debug ); var out = new OUTPUT( _opts ); var v = new HMR.verbs[ this.name() ](); v.on( 'hmr:status', function() { out.do.apply( out, arguments ); }); diff --git a/src/out.js b/src/cli/out.js similarity index 97% rename from src/out.js rename to src/cli/out.js index fd3912e..f76020d 100644 --- a/src/out.js +++ b/src/cli/out.js @@ -11,16 +11,16 @@ Output routines for HackMyResume. var chalk = require('chalk') - , HME = require('./core/event-codes') + , HME = require('../core/event-codes') , _ = require('underscore') - , Class = require('./utils/class.js') + , Class = require('../utils/class.js') , PATH = require('path') , pad = require('string-padding'); /** - A stateful output handler. + A stateful output handler. All HMR console output handled here. */ var OutputHandler = module.exports = Class.extend({ diff --git a/src/use.txt b/src/cli/use.txt similarity index 100% rename from src/use.txt rename to src/cli/use.txt diff --git a/src/core/error-handler.js b/src/core/error-handler.js index e61120b..5596a0f 100644 --- a/src/core/error-handler.js +++ b/src/core/error-handler.js @@ -107,7 +107,7 @@ Error-handling routines for HackMyResume. }).join( chalk.yellow(', ')) + chalk.yellow(").\n\n"); msg += chalk.gray(FS.readFileSync( - PATH.resolve(__dirname, '../use.txt'), 'utf8' )); + PATH.resolve(__dirname, '../cli/use.txt'), 'utf8' )); break; case HACKMYSTATUS.invalidCommand: diff --git a/src/index.js b/src/index.js index 3de0db6..9ae925a 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,7 @@ Command-line interface (CLI) for HackMyResume. try { - var main = require('./main'); + var main = require('./cli/main'); main( process.argv ); } diff --git a/test/test-stdout.js b/test/test-stdout.js index b3d4c1b..c72c707 100644 --- a/test/test-stdout.js +++ b/test/test-stdout.js @@ -1,6 +1,6 @@ var chai = require('chai') , expect = chai.expect - , HMRMAIN = require('../src/main') + , HMRMAIN = require('../src/cli/main') , CHALK = require('chalk') , FS = require('fs') , PATH = require('path') @@ -32,7 +32,7 @@ describe('Testing Ouput interface', function () { try { args.unshift( process.argv[1] ); args.unshift( process.argv[0] ); - var HMRMAIN = require('../src/main'); + var HMRMAIN = require('../src/cli/main'); HMRMAIN( args ); } catch( ex ) { @@ -61,7 +61,7 @@ describe('Testing Ouput interface', function () { var title = '*** HackMyResume v1.5.2 ***'; var feedMe = 'Please feed me a resume in FRESH or JSON Resume format.'; - var manPage = FS.readFileSync( PATH.resolve( __dirname, '../src/use.txt' ), 'utf8'); + var manPage = FS.readFileSync( PATH.resolve( __dirname, '../src/cli/use.txt' ), 'utf8'); run('HMR should output a help string when no command is specified', [], [ title, 'Please give me a command (BUILD, ANALYZE, VALIDATE, CONVERT, or NEW).' ]);