@@ -4,12 +4,13 @@ const npminfo = Promise.promisify(npm.info, npm);
44const format = require ( 'util' ) . format ;
55const inspect = require ( 'util' ) . inspect ;
66const request = require ( 'request' ) ;
7+ const unescape = require ( 'lodash.unescape' ) ;
78
89module . exports = {
910 init : function ( client , imports ) {
10- const ready = Promise . promisify ( npm . load , npm ) ( { } ) ;
11+ const npm_ready = Promise . promisify ( npm . load , npm ) ( { } ) ;
1112
12- ready . catch ( function ( err ) {
13+ npm_ready . catch ( function ( err ) {
1314 client . error ( 'Plugin-JSHelp' , err . name ) ;
1415 client . error ( 'Plugin-JSHelp' , err . stack ) ;
1516 } ) ;
@@ -21,7 +22,7 @@ module.exports = {
2122 return ;
2223 }
2324
24- return ready
25+ return npm_ready
2526 . then ( function ( ) {
2627 return new Promise ( function ( resolve , reject ) {
2728 npm . commands . info ( [ command . args [ 0 ] , 'name' , 'description' ] , true , function ( err , res ) {
@@ -66,7 +67,15 @@ module.exports = {
6667 } ) ;
6768 } )
6869 . then ( function ( res ) {
69- return format ( '%s - %s' , res . url , res . titleNoFormatting ) ;
70+ // Turn > into >, ect.
71+ // Strip the " | MDN" from end of title.
72+ return {
73+ url : res . url ,
74+ title : unescape ( res . titleNoFormatting . slice ( 0 , - 6 ) )
75+ } ;
76+ } )
77+ . then ( function ( res ) {
78+ return format ( "%s - %s" , res . url , res . title )
7079 } )
7180 . catch ( function ( err ) {
7281 client . error ( 'Plugin-JSHelp' , err . name ) ;
0 commit comments