File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,16 @@ export default class Model {
1616 return configuration . typescript ? templatesTypescript : templatesJavascript ;
1717 }
1818
19+ getWorkspacePath ( ) {
20+ const workspaces = vscode . workspace . workspaceFolders ;
21+
22+ if ( workspaces ) {
23+ return workspaces [ 0 ] . uri . toString ( ) . split ( ":" ) [ 1 ] ;
24+ }
25+
26+ return null ;
27+ }
28+
1929 createComponent ( contextUri : string ) {
2030 vscode . window
2131 . showInputBox ( {
@@ -26,9 +36,7 @@ export default class Model {
2636 . then ( ( name ) => {
2737 if ( ! name ) return ;
2838
29- const workspacePath = vscode . workspace . workspaceFolders [ 0 ] . uri
30- . toString ( )
31- . split ( ":" ) [ 1 ] ;
39+ const workspacePath = this . getWorkspacePath ( ) ;
3240 const folderPath = `${ contextUri || workspacePath } /${ name } ` ;
3341
3442 this . createFolder ( folderPath ) ;
@@ -51,9 +59,7 @@ export default class Model {
5159 . then ( ( name ) => {
5260 if ( ! name ) return ;
5361
54- const workspacePath = vscode . workspace . workspaceFolders [ 0 ] . uri
55- . toString ( )
56- . split ( ":" ) [ 1 ] ;
62+ const workspacePath = this . getWorkspacePath ( ) ;
5763 const folderPath = `${ contextUri || workspacePath } /${ name } ` ;
5864
5965 this . createFolder ( folderPath ) ;
@@ -134,7 +140,7 @@ export default class Model {
134140 fs . writeFile ( `${ path } /${ name } ` , content , this . handleError ) ;
135141 }
136142
137- handleError ( error ) {
143+ handleError ( error : any ) {
138144 if ( error ) {
139145 vscode . window . showErrorMessage ( error ) ;
140146 }
Original file line number Diff line number Diff line change 1- export const index = ( name ) => `export * from './${ name } ';\n` ;
1+ export const index = ( name : string ) => `export * from './${ name } ';\n` ;
22
3- export const indexFela = ( name , dependencies : boolean ) => `${
3+ export const indexFela = ( name : string , dependencies : boolean ) => `${
44 dependencies
55 ? "import { connectFela } from '../../dependencies'"
66 : "import { connect as connectFela } from 'react-fela'"
@@ -57,8 +57,7 @@ ${name}.propTypes = {
5757};
5858` ;
5959
60- export const styles = ( dependencies : boolean ) =>
61- "export const container = () => ({});\n" ;
60+ export const styles = ( ) => "export const container = () => ({});\n" ;
6261
6362export const component = ( name : string , dependencies : boolean ) => `${
6463 dependencies
Original file line number Diff line number Diff line change @@ -31,19 +31,13 @@ export const felaComponent = (
3131 : "import React from 'react';\nimport type { FelaWithStylesProps } from 'react-fela';"
3232}
3333${ getExtendPropImport ( typescriptFelaTheme , typescriptFelaExtendProp ) }
34- ${
35- typescriptFelaExtendProp
36- ? `import * as felaRules from './${ name } .rules';`
37- : ""
38- }
34+ import * as felaRules from './${ name } .rules';
3935
4036export interface ${ name } OwnProps {
4137 ${ getExtendProp ( typescriptFelaTheme , typescriptFelaExtendProp ) }
4238}
4339
44- interface ${ name } Props extends FelaWithStylesProps<${ name } OwnProps, ${
45- typescriptFelaExtendProp ? "typeof felaRules" : "{}"
46- } >, ${ name } OwnProps {}
40+ interface ${ name } Props extends FelaWithStylesProps<${ name } OwnProps, typeof felaRules> {}
4741
4842export const ${ name } = ({ styles }: ${ name } Props) => {
4943 return (
You can’t perform that action at this time.
0 commit comments