From b8c3c74afc3767122e09edc55087daba92545a34 Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Wed, 27 Feb 2019 10:57:33 +0100 Subject: [PATCH 1/2] Remove _.isPlainObject calls in divert.js (x2) Also worth noting: these two modules are almost exact duplicates. As a follow-up I am going to look at de-duping them. Related: https://github.com/liferay/liferay-themes-sdk/issues/141 --- packages/generator-liferay-theme/lib/divert/index.js | 9 +++++++-- packages/liferay-theme-tasks/lib/divert/index.js | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/generator-liferay-theme/lib/divert/index.js b/packages/generator-liferay-theme/lib/divert/index.js index e6161f00..ce34604e 100644 --- a/packages/generator-liferay-theme/lib/divert/index.js +++ b/packages/generator-liferay-theme/lib/divert/index.js @@ -1,6 +1,11 @@ 'use strict'; -let _ = require('lodash'); +function isPlainObject(value) { + return ( + value !== null && + Object.prototype.toString.call(value) === '[object Object]' + ); +} function divert(moduleName, version) { version = version || divert.defaultVersion; @@ -30,7 +35,7 @@ function safeRequire(moduleName) { } } - if (!_.isPlainObject(module)) { + if (!isPlainObject(module)) { throw new Error( 'Only modules exporting plain objects can be used with divert' ); diff --git a/packages/liferay-theme-tasks/lib/divert/index.js b/packages/liferay-theme-tasks/lib/divert/index.js index af9f6bbd..96c61bd9 100644 --- a/packages/liferay-theme-tasks/lib/divert/index.js +++ b/packages/liferay-theme-tasks/lib/divert/index.js @@ -1,6 +1,11 @@ 'use strict'; -let _ = require('lodash'); +function isPlainObject(value) { + return ( + value !== null && + Object.prototype.toString.call(value) === '[object Object]' + ); +} let lfrThemeConfig = require('../liferay_theme_config'); @@ -30,7 +35,7 @@ function safeRequire(moduleName) { } } - if (!_.isPlainObject(module)) { + if (!isPlainObject(module)) { throw new Error( 'Only modules exporting plain objects can be used with divert' ); From d4b4e40eef7fac003a9a91f3add5da2faa025cb7 Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Wed, 27 Feb 2019 12:01:02 +0100 Subject: [PATCH 2/2] Remove stray references to divert Required but never used. --- .../lib/divert/common/kickstart_prompt_helpers.js | 1 - packages/liferay-theme-tasks/tasks/deploy.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/packages/liferay-theme-tasks/lib/divert/common/kickstart_prompt_helpers.js b/packages/liferay-theme-tasks/lib/divert/common/kickstart_prompt_helpers.js index 53fd7fcf..7d3f0859 100644 --- a/packages/liferay-theme-tasks/lib/divert/common/kickstart_prompt_helpers.js +++ b/packages/liferay-theme-tasks/lib/divert/common/kickstart_prompt_helpers.js @@ -3,7 +3,6 @@ const inquirer = require('inquirer'); const _ = require('lodash'); -const divert = require('../../divert'); const GlobalModulePrompt = require('../../prompts/global_module_prompt'); const NPMModulePrompt = require('../../prompts/npm_module_prompt'); const themeUtil = require('../../util'); diff --git a/packages/liferay-theme-tasks/tasks/deploy.js b/packages/liferay-theme-tasks/tasks/deploy.js index a92df48b..e6c308c7 100644 --- a/packages/liferay-theme-tasks/tasks/deploy.js +++ b/packages/liferay-theme-tasks/tasks/deploy.js @@ -8,8 +8,6 @@ const lfrThemeConfig = require('../lib/liferay_theme_config'); const themeUtil = require('../lib/util'); const WarDeployer = require('../lib/war_deployer'); -const divert = require('../lib/divert'); - const themeConfig = lfrThemeConfig.getConfig(true); const DEPLOYMENT_STRATEGIES = themeUtil.DEPLOYMENT_STRATEGIES;