@@ -6,6 +6,7 @@ import Promise from 'bluebird';
66import { useFakeTimers , spy , SinonSpy } from 'sinon' ;
77import Hexo from '../../../lib/hexo' ;
88import newConsole from '../../../lib/plugins/console/new' ;
9+ import rewire from 'rewire' ;
910type OriginalParams = Parameters < typeof newConsole > ;
1011type OriginalReturn = ReturnType < typeof newConsole > ;
1112
@@ -363,4 +364,80 @@ describe('new', () => {
363364
364365 await unlink ( path ) ;
365366 } ) ;
367+
368+ it ( 'path - number (issue #4334)' , async ( ) => {
369+ let args ;
370+ const cli = rewire ( 'hexo-cli' ) ;
371+ return cli . __with__ ( {
372+ find_pkg_1 : {
373+ default : ( _cwd , _args ) => {
374+ args = _args ;
375+ return Promise . resolve ( ) ;
376+ }
377+ }
378+ } ) ( async ( ) => {
379+ process . argv = [ 'hexo' , 'new' , '--path' , '123' , 'test' ] ;
380+ // @ts -ignore
381+ cli ( null , null ) ;
382+ args . path . should . eql ( '123' ) ;
383+ process . argv = [ ] ;
384+ } ) ;
385+ } ) ;
386+
387+ it ( 'p - number (issue #4334)' , async ( ) => {
388+ let args ;
389+ const cli = rewire ( 'hexo-cli' ) ;
390+ return cli . __with__ ( {
391+ find_pkg_1 : {
392+ default : ( _cwd , _args ) => {
393+ args = _args ;
394+ return Promise . resolve ( ) ;
395+ }
396+ }
397+ } ) ( async ( ) => {
398+ process . argv = [ 'hexo' , 'new' , '-p' , '123' , 'test' ] ;
399+ // @ts -ignore
400+ cli ( null , null ) ;
401+ args . p . should . eql ( '123' ) ;
402+ process . argv = [ ] ;
403+ } ) ;
404+ } ) ;
405+
406+ it ( 'slug - number (issue #4334)' , async ( ) => {
407+ let args ;
408+ const cli = rewire ( 'hexo-cli' ) ;
409+ return cli . __with__ ( {
410+ find_pkg_1 : {
411+ default : ( _cwd , _args ) => {
412+ args = _args ;
413+ return Promise . resolve ( ) ;
414+ }
415+ }
416+ } ) ( async ( ) => {
417+ process . argv = [ 'hexo' , 'new' , '--slug' , '123' , 'test' ] ;
418+ // @ts -ignore
419+ cli ( null , null ) ;
420+ args . slug . should . eql ( '123' ) ;
421+ process . argv = [ ] ;
422+ } ) ;
423+ } ) ;
424+
425+ it ( 's - number (issue #4334)' , async ( ) => {
426+ let args ;
427+ const cli = rewire ( 'hexo-cli' ) ;
428+ return cli . __with__ ( {
429+ find_pkg_1 : {
430+ default : ( _cwd , _args ) => {
431+ args = _args ;
432+ return Promise . resolve ( ) ;
433+ }
434+ }
435+ } ) ( async ( ) => {
436+ process . argv = [ 'hexo' , 'new' , '-s' , '123' , 'test' ] ;
437+ // @ts -ignore
438+ cli ( null , null ) ;
439+ args . s . should . eql ( '123' ) ;
440+ process . argv = [ ] ;
441+ } ) ;
442+ } ) ;
366443} ) ;
0 commit comments