Skip to content

Commit 8620104

Browse files
adamkissjescalan
authored andcommitted
Check for package.json before trying to install dependencies (#273)
The tests kept failing when running multiple times, because this Spike.new tries to install NPM dependencies without a check for existence of a package.json file, so if the new Spike project was in a child directory of another node project, it would call the 'npm install --production' on the parent instead — which is a problem, especially for repositories using yarn. This add a synchronous explicit check for 'package.json' before trying to install.
1 parent 61a2de6 commit 8620104

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ function uuid () {
151151
* @return {Promise.<String>} promise for the command output
152152
*/
153153
function npmInstall (opts) {
154+
const pkgPath = path.join(opts.root, 'package.json')
155+
if (!fs.existsSync(pkgPath)) { return }
156+
154157
return node.call(exec, 'npm install --production', { cwd: opts.root })
155158
}
156159

0 commit comments

Comments
 (0)