From 8caa571f81c11fcf05fc06f9b97c25b2830b8ae1 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Mon, 16 May 2016 10:15:26 -0400 Subject: [PATCH] skip npm i if no dependencies in package.json --- lib/template.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/template.js b/lib/template.js index c7005d8..a28a5e1 100644 --- a/lib/template.js +++ b/lib/template.js @@ -283,7 +283,10 @@ function createTargetDirectory (target) { } function installDependenciesIfPresent () { - if (!fs.existsSync(path.join(this.path, 'package.json'))) { return } + const pkgPath = path.join(this.path, 'package.json') + if (!fs.existsSync(pkgPath)) { return } + const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) + if (!pkg.dependencies) { return } this.sprout.emit('msg', 'installing npm dependencies') return exec('npm install --production', { cwd: this.path }) }