From d1653a7e9cd13ea1b4d5c14f6cb3f2edd4f4fad5 Mon Sep 17 00:00:00 2001 From: Ricky Curtice Date: Tue, 26 May 2020 11:58:53 -0700 Subject: [PATCH] fix: Prevent crash with nameless package While the workaround is to simply add a name to the package, the name field is defined as optional and NPM otherwise only warns about it's lack of existence. I tripped across this myself and found I wasn't the first one: https://stackoverflow.com/questions/59777226/npm-ci-throws-exception-cannot-read-property-length-of-undefined --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 337de71..ceb609d 100644 --- a/index.js +++ b/index.js @@ -111,7 +111,7 @@ function lifecycle (pkg, stage, wd, opts) { } function _incorrectWorkingDirectory (wd, pkg) { - return wd.lastIndexOf(pkg.name) !== wd.length - pkg.name.length + return wd.lastIndexOf(pkg.name) !== wd.length - (typeof pkg.name === 'string' ? pkg.name.length : 0) } function lifecycle_ (pkg, stage, wd, opts, env, cb) {