From e72564162bb8cbe99ed36126bdc918cef3624f5b Mon Sep 17 00:00:00 2001 From: hacksalot Date: Mon, 18 Jan 2016 17:31:08 -0500 Subject: [PATCH] Remove custom "extend" method. Replace with NPM extend. --- package.json | 1 + src/cli/main.js | 2 +- src/cli/out.js | 2 +- src/core/fresh-resume.js | 2 +- src/core/fresh-theme.js | 3 +- src/core/jrs-resume.js | 2 +- src/generators/template-generator.js | 2 +- src/utils/extend.js | 79 ---------------------------- src/verbs/build.js | 17 +++--- 9 files changed, 14 insertions(+), 96 deletions(-) delete mode 100644 src/utils/extend.js diff --git a/package.json b/package.json index 480fe76..b41ef18 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "chalk": "^1.1.1", "commander": "^2.9.0", "copy": "^0.1.3", + "extend": "^3.0.0", "fresca": "~0.4.0", "fresh-jrs-converter": "^0.2.0", "fresh-resume-starter": "^0.2.0", diff --git a/src/cli/main.js b/src/cli/main.js index 8cb6443..18ecf81 100644 --- a/src/cli/main.js +++ b/src/cli/main.js @@ -13,7 +13,7 @@ Definition of the `main` function. var HMR = require( '../hackmyapi') , PKG = require('../../package.json') , FS = require('fs') - , EXTEND = require('../utils/extend') + , EXTEND = require('extend') , chalk = require('chalk') , PATH = require('path') , HACKMYSTATUS = require('../core/status-codes') diff --git a/src/cli/out.js b/src/cli/out.js index 87f7375..1014595 100644 --- a/src/cli/out.js +++ b/src/cli/out.js @@ -18,7 +18,7 @@ Output routines for HackMyResume. , PATH = require('path') , LO = require('lodash') , FS = require('fs') - , EXTEND = require('../utils/extend') + , EXTEND = require('extend') , HANDLEBARS = require('handlebars') , YAML = require('yamljs') , printf = require('printf') diff --git a/src/core/fresh-resume.js b/src/core/fresh-resume.js index 65fc05d..952798b 100644 --- a/src/core/fresh-resume.js +++ b/src/core/fresh-resume.js @@ -11,7 +11,7 @@ Definition of the FRESHResume class. var FS = require('fs') - , extend = require('../utils/extend') + , extend = require('extend') , validator = require('is-my-json-valid') , _ = require('underscore') , __ = require('lodash') diff --git a/src/core/fresh-theme.js b/src/core/fresh-theme.js index 08fcc9b..ca65bc5 100644 --- a/src/core/fresh-theme.js +++ b/src/core/fresh-theme.js @@ -9,13 +9,12 @@ Definition of the FRESHTheme class. var FS = require('fs') - , extend = require('../utils/extend') , validator = require('is-my-json-valid') , _ = require('underscore') , PATH = require('path') , parsePath = require('parse-filepath') , pathExists = require('path-exists').sync - , EXTEND = require('../utils/extend') + , EXTEND = require('extend') , moment = require('moment') , READFILES = require('recursive-readdir-sync'); diff --git a/src/core/jrs-resume.js b/src/core/jrs-resume.js index f464886..5e6abc9 100644 --- a/src/core/jrs-resume.js +++ b/src/core/jrs-resume.js @@ -11,7 +11,7 @@ Definition of the JRSResume class. var FS = require('fs') - , extend = require('../utils/extend') + , extend = require('extend') , validator = require('is-my-json-valid') , _ = require('underscore') , PATH = require('path') diff --git a/src/generators/template-generator.js b/src/generators/template-generator.js index f25ae84..fa8e542 100644 --- a/src/generators/template-generator.js +++ b/src/generators/template-generator.js @@ -16,7 +16,7 @@ Definition of the TemplateGenerator class. TODO: Refactor , parsePath = require('parse-filepath') , MKDIRP = require('mkdirp') , BaseGenerator = require( './base-generator' ) - , EXTEND = require('../utils/extend') + , EXTEND = require('extend') , FRESHTheme = require('../core/fresh-theme') , JRSTheme = require('../core/jrs-theme'); diff --git a/src/utils/extend.js b/src/utils/extend.js deleted file mode 100644 index 0daeaa4..0000000 --- a/src/utils/extend.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -Definition of the `extend` method. -@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. -@module extend.js -*/ - -function _extend() { - - function isPlainObject( obj ) { - if ((typeof obj !== "object") || obj.nodeType || - (obj !== null && obj === obj.window)) { - return false; - } - if (obj.constructor && - !hasOwnProperty.call( obj.constructor.prototype, "isPrototypeOf" )) { - return false; - } - return true; - } - - var options - , name - , src - , copy - , copyIsArray - , clone - , target = arguments[0] || {} - , i = 1 - , length = arguments.length - , deep = false; - - // Handle a deep copy situation - if (typeof target === "boolean") { - deep = target; - // Skip the boolean and the target - target = arguments[i] || {}; - i++; - } - - // Handle case when target is a string or something (possible in deep copy) - //if (typeof target !== "object" && !jQuery.isFunction(target)) - if (typeof target !== "object" && typeof target !== "function") - target = {}; - - for (; i < length; i++) { - // Only deal with non-null/undefined values - if ((options = arguments[i]) !== null) { - // Extend the base object - for (name in options) { - src = target[name]; - copy = options[name]; - - // Prevent never-ending loop - if (target === copy) continue; - - // Recurse if we're merging plain objects or arrays - if (deep && copy && (isPlainObject(copy) || - (copyIsArray = (copy.constructor === Array)))) { - if (copyIsArray) { - copyIsArray = false; - clone = src && (src.constructor === Array) ? src : []; - } else { - clone = src && isPlainObject(src) ? src : {}; - } - // Never move original objects, clone them - target[name] = _extend(deep, clone, copy); - // Don't bring in undefined values - } else if (copy !== undefined) { - target[name] = copy; - } - } - } - } - - // Return the modified object - return target; -} - -module.exports = _extend; diff --git a/src/verbs/build.js b/src/verbs/build.js index 413a6d7..267b080 100644 --- a/src/verbs/build.js +++ b/src/verbs/build.js @@ -10,26 +10,23 @@ Implementation of the 'build' verb for HackMyResume. - var PATH = require('path') + var _ = require('underscore') + , PATH = require('path') , FS = require('fs') , MD = require('marked') , MKDIRP = require('mkdirp') - , EXTEND = require('../utils/extend') + , extend = require('extend') + , parsePath = require('parse-filepath') + , RConverter = require('fresh-jrs-converter') , HMSTATUS = require('../core/status-codes') , HMEVENT = require('../core/event-codes') - , RConverter = require('fresh-jrs-converter') , RTYPES = { FRESH: require('../core/fresh-resume'), JRS: require('../core/jrs-resume') } - , parsePath = require('parse-filepath') , _opts = require('../core/default-options') - , FluentTheme = require('../core/fresh-theme') + , FRESHTheme = require('../core/fresh-theme') , JRSTheme = require('../core/jrs-theme') , ResumeFactory = require('../core/resume-factory') - , _ = require('underscore') , _fmts = require('../core/default-formats') - , extend = require('../utils/extend') - , chalk = require('chalk') - , pad = require('string-padding') , Verb = require('../verbs/verb'); var _err, _log, _rezObj; @@ -346,7 +343,7 @@ Implementation of the 'build' verb for HackMyResume. // Create a FRESH or JRS theme object var theTheme = _opts.theme.indexOf('jsonresume-theme-') > -1 ? - new JRSTheme().open(tFolder) : new FluentTheme().open( tFolder ); + new JRSTheme().open(tFolder) : new FRESHTheme().open( tFolder ); // Cache the theme object _opts.themeObj = theTheme;