Skip to content

Commit 63290c7

Browse files
author
Sebastian McKenzie
committed
allow install scripts for optional dependencies to fail - fixes #40
1 parent d88fffe commit 63290c7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/package-install-scripts.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ export default class PackageInstallScripts {
5252
return await executeLifecycleScript(this.config, loc, cmds, pkg);
5353
} catch (err) {
5454
err.message = `${loc}: ${err.message}`;
55-
throw err;
55+
56+
let ref = pkg.reference;
57+
invariant(ref, "expected reference");
58+
59+
if (ref.optional) {
60+
this.reporter.error(`Error running install script for optional dependency: ${err.message}`);
61+
this.reporter.info("This module is OPTIONAL, you can safely ignore this error");
62+
return [];
63+
} else {
64+
throw err;
65+
}
5666
}
5767
}
5868

0 commit comments

Comments
 (0)