From 36e855237fc0f5509f8271dbe6ed97e5ca0180af Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 15 Feb 2018 10:47:36 -0700 Subject: [PATCH] replaced json -> hjson loader --- package.json | 3 ++- plugins.js | 5 ++++- webpack.config.js | 2 +- yarn.lock | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index af45c04a5..591ccbc41 100644 --- a/package.json +++ b/package.json @@ -113,13 +113,14 @@ "hammerjs": "^2.0.8", "helmet": "3.8.2", "history": "^3.0.0", + "hjson": "^3.1.1", + "hjson-loader": "^1.0.0", "immutability-helper": "^2.2.0", "imports-loader": "^0.7.1", "inquirer": "^3.2.2", "inquirer-autocomplete-prompt": "^0.12.1", "ioredis": "3.1.4", "joi": "^10.6.0", - "json-loader": "^0.5.7", "jsonwebtoken": "^7.4.3", "jwt-decode": "^2.2.0", "keymaster": "^1.6.2", diff --git a/plugins.js b/plugins.js index 6f65fc9a1..05d245c8a 100644 --- a/plugins.js +++ b/plugins.js @@ -4,6 +4,7 @@ const resolve = require('resolve'); const debug = require('debug')('talk:plugins'); const Joi = require('joi'); const amp = require('app-module-path'); +const hjson = require('hjson'); const pkg = require('./package.json'); const PLUGINS_JSON = process.env.TALK_PLUGINS_JSON; @@ -33,7 +34,9 @@ try { pluginsPath = defaultPlugins; } - plugins = require(pluginsPath); + // Load/parse the plugin content using hjson. + const pluginContent = fs.readFileSync(pluginsPath, 'utf8'); + plugins = hjson.parse(pluginContent); } catch (err) { if (err.code === 'ENOENT') { console.error( diff --git a/webpack.config.js b/webpack.config.js index 6a018caba..d488a0a0f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -74,7 +74,7 @@ const config = { }, }, { - loader: 'json-loader', + loader: 'hjson-loader', test: /\.(json|yml)$/, exclude: /node_modules/, }, diff --git a/yarn.lock b/yarn.lock index 164064e2b..ef8ed5e42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4022,6 +4022,16 @@ history@^3.0.0: query-string "^4.2.2" warning "^3.0.0" +hjson-loader@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/hjson-loader/-/hjson-loader-1.0.0.tgz#d6547d77eebbfc8ab9df45c1db90c6c061cc88fc" + dependencies: + loader-utils "^0.2.12" + +hjson@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/hjson/-/hjson-3.1.1.tgz#eaab95eebc6c0c749442219a817d9b4ff0070dd2" + hmac-drbg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -5076,7 +5086,7 @@ jsmin@1.x: version "1.0.1" resolved "https://registry.yarnpkg.com/jsmin/-/jsmin-1.0.1.tgz#e7bd0dcd6496c3bf4863235bf461a3d98aa3b98c" -json-loader@^0.5.4, json-loader@^0.5.7: +json-loader@^0.5.4: version "0.5.7" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.7.tgz#dca14a70235ff82f0ac9a3abeb60d337a365185d" @@ -5327,7 +5337,7 @@ loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" -loader-utils@^0.2.15: +loader-utils@^0.2.12, loader-utils@^0.2.15: version "0.2.17" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" dependencies: