From c008c549a13012f51e10a78ba3f1012eb7c2cd20 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Mon, 16 May 2016 09:24:21 -0400 Subject: [PATCH 1/2] only install production dependencies --- lib/template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template.js b/lib/template.js index 6862835..3213a36 100644 --- a/lib/template.js +++ b/lib/template.js @@ -270,7 +270,7 @@ function createTargetDirectory (target) { function installDependenciesIfPresent () { if (!fs.existsSync(path.join(this.path, 'package.json'))) { return } this.sprout.emit('msg', 'installing npm dependencies') - return exec('npm install', { cwd: this.path }) + return exec('npm install --production', { cwd: this.path }) } function loadConfigFile () { From 5ab7a1f6e18418467dae2401037de91458b8b030 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Mon, 16 May 2016 09:36:11 -0400 Subject: [PATCH 2/2] more clear joi error messages --- lib/template.js | 28 ++++++++++++++++++++++++---- test/test.js | 4 ++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/template.js b/lib/template.js index 3213a36..c7005d8 100644 --- a/lib/template.js +++ b/lib/template.js @@ -44,7 +44,12 @@ class Template { generatorsFolderName: Joi.string().default('generators') }) - let options = Joi.validate(_options, schema) + let options = Joi.validate(_options, schema, { + language: { + messages: { wrapArrays: false }, + object: { child: '!![sprout constructor] option {{reason}}' } + } + }) if (options.error) { throw options.error } options = options.value @@ -88,7 +93,12 @@ class Template { Joi.assert(target, Joi.string().required().label('target')) - return node.call(Joi.validate, opts, schema).with(this) + return node.call(Joi.validate, opts, schema, { + language: { + messages: { wrapArrays: false }, + object: { child: '!![sprout init] option {{reason}}' } + } + }).with(this) .then((res) => { opts = res }) .then(this.update.bind(this)) .then(validateTemplate) @@ -151,7 +161,12 @@ class Template { generatorArgs: Joi.array().single().default([]) }) - return node.call(Joi.validate, args, schema) + return node.call(Joi.validate, args, schema, { + language: { + messages: { wrapArrays: false }, + object: { child: '!![sprout generator] option {{reason}}' } + } + }) .then((res) => { args = res }) .then(() => { if (!fs.existsSync(target)) { @@ -287,7 +302,12 @@ function loadConfigFile () { defaults: Joi.object() }) - const result = Joi.validate(require(initPath), schema) + const result = Joi.validate(require(initPath), schema, { + language: { + messages: { wrapArrays: false }, + object: { child: '!![sprout init.js] option {{reason}}' } + } + }) if (result.error) { throw result.error } this.init = result.value diff --git a/test/test.js b/test/test.js index 4a53f12..69954a8 100644 --- a/test/test.js +++ b/test/test.js @@ -1513,7 +1513,7 @@ describe('template', } ).catch( function (error) { - error.toString().should.eq('ValidationError: child "target" fails because ["target" must be a string]') + error.toString().should.eq('ValidationError: [sprout generator] option "target" must be a string') return template.remove(name).then( function () { return rimraf(target, done) @@ -1578,7 +1578,7 @@ describe('template', } ).catch( function (error) { - error.toString().should.eq('ValidationError: child "generator" fails because ["generator" must be a string]') + error.toString().should.eq('ValidationError: [sprout generator] option "generator" must be a string') return template.remove(name).then( function () { return rimraf(target, done)