11import { CommentPermissionType , CreateNoteOptions , NotePermissionRole } from '@hackmd/api/dist/type'
22import { Flags , ux } from '@oclif/core'
3- import fs from 'fs'
3+ import fs from 'node: fs'
44
55import HackMDCommand from '../../command'
66import { commentPermission , editor , noteContent , notePermission , noteTitle , teamPath } from '../../flags'
@@ -17,7 +17,7 @@ ID Title User Path T
1717raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q null ` ,
1818
1919 'Or you can pipe content via Unix pipeline:' ,
20- 'cat README.md | hackmd-cli notes create --teamPath=CLI-test'
20+ 'cat README.md | hackmd-cli notes create --teamPath=CLI-test' ,
2121 ]
2222
2323 static flags = {
@@ -36,13 +36,13 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
3636 const { flags} = await this . parse ( Create )
3737 const pipeString = safeStdinRead ( )
3838
39- const { teamPath} = flags
39+ const { teamPath, title , content , readPermission , writePermission , commentPermission } = flags
4040 const options : CreateNoteOptions = {
41- title : flags . title ,
42- content : pipeString || flags . content ,
43- readPermission : flags . readPermission as NotePermissionRole ,
44- writePermission : flags . writePermission as NotePermissionRole ,
45- commentPermission : flags . commentPermission as CommentPermissionType
41+ title : title ,
42+ content : pipeString || content ,
43+ readPermission : readPermission as NotePermissionRole ,
44+ writePermission : writePermission as NotePermissionRole ,
45+ commentPermission : commentPermission as CommentPermissionType ,
4646 }
4747
4848 if ( ! teamPath ) {
@@ -55,8 +55,8 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
5555 await openEditor ( mdFile )
5656
5757 options . content = fs . readFileSync ( mdFile ) . toString ( )
58- } catch ( e ) {
59- this . error ( e as Error )
58+ } catch ( error ) {
59+ this . error ( error as Error )
6060 }
6161 }
6262
@@ -70,18 +70,18 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
7070 } ,
7171 title : { } ,
7272 userPath : {
73- header : 'User path'
73+ header : 'User path' ,
7474 } ,
7575 teamPath : {
76- header : 'Team path'
77- }
76+ header : 'Team path' ,
77+ } ,
7878 } , {
7979 printLine : this . log . bind ( this ) ,
80- ...flags
80+ ...flags ,
8181 } )
82- } catch ( e ) {
82+ } catch ( error ) {
8383 this . log ( 'Create team note failed' )
84- this . error ( e as Error )
84+ this . error ( error as Error )
8585 }
8686 }
8787}
0 commit comments