File tree Expand file tree Collapse file tree 4 files changed +28
-5
lines changed Expand file tree Collapse file tree 4 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ cat << EOF > .env.json
3+ {
4+ "commit": {
5+ "full": "` git rev-parse HEAD` ",
6+ "short": "` git rev-parse --short HEAD` "
7+ },
8+ "node": "` node -v` ",
9+ "npm": "` npm -v` "
10+ }
11+ EOF
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ Choose one of the following ways to install leetcode-cli:
2626** From source code**
2727
2828 $ git clone http://github.com/skygragon/leetcode-cli
29- $ cd leetcode-cli && npm install && sudo npm install -g .
29+ $ cd leetcode-cli && npm install && sudo npm install -g --unsafe-perm .
3030
3131Then verify the result:
3232
Original file line number Diff line number Diff line change @@ -12,11 +12,22 @@ function prettyLine(k, v) {
1212 log . info ( sprintf ( '%-20s %s' , k + ':' , v ) ) ;
1313}
1414
15- cmd . handler = function ( argv ) {
15+ function getVersion ( ) {
1616 var version = require ( '../../package.json' ) . version ;
17- if ( log . getLevel ( ) >= log . levels . INFO ) {
17+
18+ try {
19+ var commit = require ( '../../.env.json' ) . commit . short ;
20+ if ( commit ) version += '-' + commit ;
21+ } catch ( e ) { }
22+
23+ return version ;
24+ }
25+
26+ cmd . handler = function ( argv ) {
27+ var version = getVersion ( ) ;
28+
29+ if ( log . getLevel ( ) >= log . levels . INFO )
1830 return log . info ( version ) ;
19- }
2031
2132 var logo = [
2233 ' _ _ _ ' ,
Original file line number Diff line number Diff line change 88 },
99 "scripts" : {
1010 "lint" : " eslint lib/ test/" ,
11- "test" : " npm run lint && nyc mocha test/"
11+ "test" : " npm run lint && nyc mocha test/" ,
12+ "prepare" : " ./bin/prepare"
1213 },
1314 "repository" : {
1415 "type" : " git" ,
You can’t perform that action at this time.
0 commit comments