Skip to content

Commit

Permalink
More discreet post-install
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Nov 19, 2019
1 parent bd3f7c8 commit 228d8e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ publishTask('ejs', ['build'], function () {
'README.md',
'LICENSE',
'package.json',
'postinstall.js',
'ejs.js',
'ejs.min.js',
'lib/**'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
15 changes: 15 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -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);

This comment has been minimized.

Copy link
@cesine

cesine Jul 20, 2020

Introducing let requires consumers to drop support for older node versions.

For example, nodeunit is now failing in several projects which use older node:

https://travis-ci.org/github/caolan/nodeunit/jobs/710077156

$ npm install 
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.18","npm":"2.15.11"})
> [email protected] postinstall /home/travis/build/caolan/nodeunit/node_modules/ejs
> node ./postinstall.js
/home/travis/build/caolan/nodeunit/node_modules/ejs/postinstall.js:9
let envDisable = isTrue(process.env.DISABLE_OPENCOLLECTIVE) || isTrue(process.
^^^
SyntaxError: Unexpected strict mode reserved word
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Screen Shot 2020-07-20 at 1 12 52 PM

Ideally it should be not be done on a patch version v2.7.2...v2.7.3 since most repos will automatically pull those in

This comment has been minimized.

Copy link
@cesine

cesine Jul 20, 2020

I cant make a PR to fix since there isn't a branch for 2.x support, but if there was, then this patch cesine#1 would restore install-ability for consumers who were using ^2.0 in their package.json

i put in an issue in case others are also looking for a fix #534

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');
}


0 comments on commit 228d8e4

Please sign in to comment.