From 9466a8c0dd2a67b4e2aa3814c477d6155ac4d432 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Sat, 9 Jan 2016 05:29:45 -0500 Subject: [PATCH] Remove spawn-watch. No longer necessary. --- src/core/spawn-watch.js | 22 ------------- src/main.js | 3 +- test/test-stdout.js | 69 +++++++++++++++++++++++++++++++++++++++++ test/test-themes.js | 3 +- 4 files changed, 71 insertions(+), 26 deletions(-) delete mode 100644 src/core/spawn-watch.js create mode 100644 test/test-stdout.js diff --git a/src/core/spawn-watch.js b/src/core/spawn-watch.js deleted file mode 100644 index ac06849..0000000 --- a/src/core/spawn-watch.js +++ /dev/null @@ -1,22 +0,0 @@ -/** -@module spawn-watch.js -*/ - -(function() { - -// Catch various out-of-band child process errors such as ENOENT for PDFs -// http://stackoverflow.com/q/27688804 -var SpawnWatcher = module.exports = function() { - var childProcess = require("child_process"); - var oldSpawn = childProcess.spawn; - childProcess.spawn = function() { - return oldSpawn.apply(this, arguments) - .on('error', function(err) { - require('./error-handler').err( err, false ); - }); - }; -}(); - -//SpawnWatcher(); - -}()); diff --git a/src/main.js b/src/main.js index f4de7bb..ca1ddca 100644 --- a/src/main.js +++ b/src/main.js @@ -10,8 +10,7 @@ - var SPAWNW = require('./core/spawn-watch') - , HMR = require( './hackmyapi') + var HMR = require( './hackmyapi') , PKG = require('../package.json') , FS = require('fs') , EXTEND = require('./utils/extend') diff --git a/test/test-stdout.js b/test/test-stdout.js new file mode 100644 index 0000000..aa425cb --- /dev/null +++ b/test/test-stdout.js @@ -0,0 +1,69 @@ +var chai = require('chai') + , expect = chai.expect + , HMRMAIN = require('../src/main') + , CHALK = require('chalk') + , _ = require('underscore'); + +// Disable colors for easier output testing +CHALK.enabled = false; + +describe('Testing Ouput interface', function () { + + var gather = ''; + var ConsoleLogOrg = console.log; + + function MyConsoleLog( msg ) { + gather += msg; + ConsoleLogOrg.apply(this, arguments); + } + + function HackMyResumeStub( args ) { + + try { + args.unshift( process.argv[1] ); + args.unshift( process.argv[0] ); + var HMRMAIN = require('../src/main'); + HMRMAIN( args ); + } + catch( ex ) { + require('../src/core/error-handler').err( ex, false ); + } + } + + function run( title, args, tests ) { + it( title, function() { + gather = ''; + console.log = MyConsoleLog; + HackMyResumeStub( args ); + console.log = ConsoleLogOrg; + expect( + _.all( tests, function(t) { + return gather.indexOf(t) > -1; + }) + ).to.equal(true); + }); + } + + var title = '*** HackMyResume v1.5.2 ***'; + var feedMe = 'Please feed me a resume in FRESH or JSON Resume format.'; + + run('HMR should output a help string when no command is specified', + [], [ title, 'Please give me a command (BUILD, ANALYZE, VALIDATE, CONVERT, or NEW).' ]); + + run('BUILD should output a tip when no source is specified', + ['build'], [ title, feedMe ]); + + run('VALIATE should output a tip when no source is specified', + ['validate'], [ title, feedMe ]); + + run('ANALYZE should output a tip when no source is specified', + ['analyze'], [ title, feedMe ]); + + run('CONVERT should output a tip when no source is specified', + ['convert'], [ title, feedMe ]); + + run('NEW should output a tip when no source is specified', + ['new'], [ title, 'Please specify the filename of the resume to create.' ]); + + +}); diff --git a/test/test-themes.js b/test/test-themes.js index 4d96c7d..7cc7440 100644 --- a/test/test-themes.js +++ b/test/test-themes.js @@ -1,6 +1,5 @@ -var SPAWNWATCHER = require('../src/core/spawn-watch') - , chai = require('chai') +var chai = require('chai') , expect = chai.expect , should = chai.should() , path = require('path')