From 228d8e45b7ced2afd3e596c13d44aed464e57e43 Mon Sep 17 00:00:00 2001 From: mde Date: Mon, 18 Nov 2019 17:58:56 -0800 Subject: [PATCH] More discreet post-install --- jakefile.js | 1 + package.json | 2 +- postinstall.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 postinstall.js diff --git a/jakefile.js b/jakefile.js index 24c78afd..7b9e50fc 100644 --- a/jakefile.js +++ b/jakefile.js @@ -60,6 +60,7 @@ publishTask('ejs', ['build'], function () { 'README.md', 'LICENSE', 'package.json', + 'postinstall.js', 'ejs.js', 'ejs.min.js', 'lib/**' diff --git a/package.json b/package.json index 2bbf82af..5e373fc5 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,6 @@ "node": ">=0.10.0" }, "scripts": { - "postinstall": "node -e \"console.log('Thank you for installing \\u001b[35mEJS\\u001b[0m: built with the \\u001b[32mJake\\u001b[0m JavaScript build tool (\\u001b[32mhttps://jakejs.com/\\u001b[0m)\\n');\"" + "postinstall": "node ./postinstall.js" } } diff --git a/postinstall.js b/postinstall.js new file mode 100755 index 00000000..a1202e0f --- /dev/null +++ b/postinstall.js @@ -0,0 +1,15 @@ +#!/usr/bin/env node + +function isTrue(value) { + return !!value && value !== '0' && value !== 'false'; +} + +let envDisable = isTrue(process.env.DISABLE_OPENCOLLECTIVE) || isTrue(process.env.CI); +let logLevel = process.env.npm_config_loglevel; +let logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1; + +if (!envDisable && !logLevelDisplay) { + console.log('Thank you for installing \u001b[35mEJS\u001b[0m: built with the \u001b[32mJake\u001b[0m JavaScript build tool (\u001b[32mhttps://jakejs.com/\u001b[0m)\n'); +} + +